error migrate in codeigniter 4.2.1.0 - startup - 11-27-2022
today, i test migrate version 4.2.1.0 it info error below
Quote:H:\HELPER\SERVER\htdocs\ciall\ci4\ci422>php spark migrate:create answer_true
PHP Warning: Undefined array key "HTTP_HOST" in H:\HELPER\SERVER\htdocs\ciall\ci4\ci422\app\Config\Constants.php on line 30
Warning: Undefined array key "HTTP_HOST" in H:\HELPER\SERVER\htdocs\ciall\ci4\ci422\app\Config\Constants.php on line 30
PHP Fatal error: Uncaught TypeError: CodeIgniter\HTTP\URI: etHost(): Argument #1 ($str) must be of type string, null given, called in H:\HELPER\SERVER\htdocs\ciall\ci4\ci422\vendor\codeigniter4\framework\system\HTTP\IncomingRequest.php on line 404 and defined in H:\HELPER\SERVER\htdocs\ciall\ci4\ci422\vendor\codeigniter4\framework\system\HTTP\URI.php:691
Stack trace:
#0 H:\HELPER\SERVER\htdocs\ciall\ci4\ci422\vendor\codeigniter4\framework\system\HTTP\IncomingRequest.php(404): CodeIgniter\HTTP\URI->setHost(NULL)
#1 H:\HELPER\SERVER\htdocs\ciall\ci4\ci422\vendor\codeigniter4\framework\system\HTTP\IncomingRequest.php(202): CodeIgniter\HTTP\IncomingRequest->setPath('', Object(Config\App))
#2 H:\HELPER\SERVER\htdocs\ciall\ci4\ci422\vendor\codeigniter4\framework\system\HTTP\IncomingRequest.php(170): CodeIgniter\HTTP\IncomingRequest->detectURI('REQUEST_URI', 'http://')
#3 H:\HELPER\SERVER\htdocs\ciall\ci4\ci422\vendor\codeigniter4\framework\system\Config\Services.php(541): CodeIgniter\HTTP\IncomingRequest->__construct(Object(Config\App), Object(CodeIgniter\HTTP\URI), '', Object(CodeIgniter\HTTP\UserAgent))
#4 H:\HELPER\SERVER\htdocs\ciall\ci4\ci422\vendor\codeigniter4\framework\system\Config\Services.php(497): CodeIgniter\Config\Services::incomingrequest(Object(Config\App), false)
#5 H:\HELPER\SERVER\htdocs\ciall\ci4\ci422\vendor\codeigniter4\framework\system\Config\BaseService.php(253): CodeIgniter\Config\Services::request(NULL, false)
#6 H:\HELPER\SERVER\htdocs\ciall\ci4\ci422\vendor\codeigniter4\framework\system\Config\BaseService.php(194): CodeIgniter\Config\BaseService::__callStatic('request', Array)
#7 H:\HELPER\SERVER\htdocs\ciall\ci4\ci422\vendor\codeigniter4\framework\system\Config\Services.php(493): CodeIgniter\Config\BaseService::getSharedInstance('request', NULL)
#8 H:\HELPER\SERVER\htdocs\ciall\ci4\ci422\vendor\codeigniter4\framework\system\Config\BaseService.php(253): CodeIgniter\Config\Services::request()
#9 H:\HELPER\SERVER\htdocs\ciall\ci4\ci422\vendor\codeigniter4\framework\system\Config\Services.php(263): CodeIgniter\Config\BaseService::__callStatic('request', Array)
#10 H:\HELPER\SERVER\htdocs\ciall\ci4\ci422\vendor\codeigniter4\framework\system\Config\BaseService.php(253): CodeIgniter\Config\Services::exceptions(Object(Config\Exceptions), NULL, NULL, false)
#11 H:\HELPER\SERVER\htdocs\ciall\ci4\ci422\vendor\codeigniter4\framework\system\Config\BaseService.php(194): CodeIgniter\Config\BaseService::__callStatic('exceptions', Array)
#12 H:\HELPER\SERVER\htdocs\ciall\ci4\ci422\vendor\codeigniter4\framework\system\Config\Services.php(259): CodeIgniter\Config\BaseService::getSharedInstance('exceptions', NULL, NULL, NULL)
#13 H:\HELPER\SERVER\htdocs\ciall\ci4\ci422\vendor\codeigniter4\framework\system\Config\BaseService.php(253): CodeIgniter\Config\Services::exceptions()
#14 H:\HELPER\SERVER\htdocs\ciall\ci4\ci422\vendor\codeigniter4\framework\system\CodeIgniter.php(178): CodeIgniter\Config\BaseService::__callStatic('exceptions', Array)
#15 H:\HELPER\SERVER\htdocs\ciall\ci4\ci422\spark(83): CodeIgniter\CodeIgniter->initialize()
#16 {main}
thrown in H:\HELPER\SERVER\htdocs\ciall\ci4\ci422\vendor\codeigniter4\framework\system\HTTP\URI.php on line 691
Fatal error: Uncaught TypeError: CodeIgniter\HTTP\URI: etHost(): Argument #1 ($str) must be of type string, null given, called in H:\HELPER\SERVER\htdocs\ciall\ci4\ci422\vendor\codeigniter4\framework\system\HTTP\IncomingRequest.php on line 404 and defined in H:\HELPER\SERVER\htdocs\ciall\ci4\ci422\vendor\codeigniter4\framework\system\HTTP\URI.php:691
Stack trace:
#0 H:\HELPER\SERVER\htdocs\ciall\ci4\ci422\vendor\codeigniter4\framework\system\HTTP\IncomingRequest.php(404): CodeIgniter\HTTP\URI->setHost(NULL)
#1 H:\HELPER\SERVER\htdocs\ciall\ci4\ci422\vendor\codeigniter4\framework\system\HTTP\IncomingRequest.php(202): CodeIgniter\HTTP\IncomingRequest->setPath('', Object(Config\App))
#2 H:\HELPER\SERVER\htdocs\ciall\ci4\ci422\vendor\codeigniter4\framework\system\HTTP\IncomingRequest.php(170): CodeIgniter\HTTP\IncomingRequest->detectURI('REQUEST_URI', 'http://')
#3 H:\HELPER\SERVER\htdocs\ciall\ci4\ci422\vendor\codeigniter4\framework\system\Config\Services.php(541): CodeIgniter\HTTP\IncomingRequest->__construct(Object(Config\App), Object(CodeIgniter\HTTP\URI), '', Object(CodeIgniter\HTTP\UserAgent))
#4 H:\HELPER\SERVER\htdocs\ciall\ci4\ci422\vendor\codeigniter4\framework\system\Config\Services.php(497): CodeIgniter\Config\Services::incomingrequest(Object(Config\App), false)
#5 H:\HELPER\SERVER\htdocs\ciall\ci4\ci422\vendor\codeigniter4\framework\system\Config\BaseService.php(253): CodeIgniter\Config\Services::request(NULL, false)
#6 H:\HELPER\SERVER\htdocs\ciall\ci4\ci422\vendor\codeigniter4\framework\system\Config\BaseService.php(194): CodeIgniter\Config\BaseService::__callStatic('request', Array)
#7 H:\HELPER\SERVER\htdocs\ciall\ci4\ci422\vendor\codeigniter4\framework\system\Config\Services.php(493): CodeIgniter\Config\BaseService::getSharedInstance('request', NULL)
#8 H:\HELPER\SERVER\htdocs\ciall\ci4\ci422\vendor\codeigniter4\framework\system\Config\BaseService.php(253): CodeIgniter\Config\Services::request()
#9 H:\HELPER\SERVER\htdocs\ciall\ci4\ci422\vendor\codeigniter4\framework\system\Config\Services.php(263): CodeIgniter\Config\BaseService::__callStatic('request', Array)
#10 H:\HELPER\SERVER\htdocs\ciall\ci4\ci422\vendor\codeigniter4\framework\system\Config\BaseService.php(253): CodeIgniter\Config\Services::exceptions(Object(Config\Exceptions), NULL, NULL, false)
#11 H:\HELPER\SERVER\htdocs\ciall\ci4\ci422\vendor\codeigniter4\framework\system\Config\BaseService.php(194): CodeIgniter\Config\BaseService::__callStatic('exceptions', Array)
#12 H:\HELPER\SERVER\htdocs\ciall\ci4\ci422\vendor\codeigniter4\framework\system\Config\Services.php(259): CodeIgniter\Config\BaseService::getSharedInstance('exceptions', NULL, NULL, NULL)
#13 H:\HELPER\SERVER\htdocs\ciall\ci4\ci422\vendor\codeigniter4\framework\system\Config\BaseService.php(253): CodeIgniter\Config\Services::exceptions()
#14 H:\HELPER\SERVER\htdocs\ciall\ci4\ci422\vendor\codeigniter4\framework\system\CodeIgniter.php(178): CodeIgniter\Config\BaseService::__callStatic('exceptions', Array)
#15 H:\HELPER\SERVER\htdocs\ciall\ci4\ci422\spark(83): CodeIgniter\CodeIgniter->initialize()
#16 {main}
thrown in H:\HELPER\SERVER\htdocs\ciall\ci4\ci422\vendor\codeigniter4\framework\system\HTTP\URI.php on line 691
can someone show me fix it ?
thank you
note
i edit some code below, and work for me =>>Config\Constants.php
PHP Code: $host = ''; if (!empty($_SERVER['HTTP_HOST'])){ $host = $_SERVER['HTTP_HOST'];} $base = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https://'.$host.dirname($_SERVER['SCRIPT_NAME']) : 'http://'.$host.dirname($_SERVER['SCRIPT_NAME']); defined('BASEURL') || define('BASEURL', $base);
RE: error migrate in codeigniter 4.2.1.0 - kenjis - 11-27-2022
Code: PHP Warning: Undefined array key "HTTP_HOST" in H:\HELPER\SERVER\htdocs\ciall\ci4\ci422\app\Config\Constants.php on line 30
Because $_SERVER['HTTP_HOST'] does not exist in CLI.
|