CodeIgniter Forums
Error: Use of undefined constant ENVIRONMENT - CI 4.1.5 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Error: Use of undefined constant ENVIRONMENT - CI 4.1.5 (/showthread.php?tid=80608)



Error: Use of undefined constant ENVIRONMENT - CI 4.1.5 - Mobostar - 11-20-2021

Hello,
I am getting this error when I run "spark" to create a migration.
Code:
$ php spark migrate:create create_posts_table
PHP Warning:  Use of undefined constant ENVIRONMENT - assumed 'ENVIRONMENT' (this will throw an Error in a future version of PHP) in vendor/codeigniter4/framework/system/Config/Factories.php on line 110

The migration is created anyway, but I wonder what this is about.

PHP 7.4.3
CI 4.1.5

Thanks


RE: Error: Use of undefined constant ENVIRONMENT - CI 4.1.5 - kenjis - 11-20-2021

I can't reproduce it.

See vendor/codeigniter4/framework/system/Config/Factories.php line 110.


RE: Error: Use of undefined constant ENVIRONMENT - CI 4.1.5 - Mobostar - 11-20-2021

The following is the "PHP stack trace" for the same error in case it helps.

Code:
PHP Stack trace:
PHP  1. {main}() /var/www/xyz.com/spark:0
PHP  2. require() /var/www/xyz.com/spark:44
PHP  3. CodeIgniter\Config\Services::codeigniter() /var/www/xyz.com/vendor/codeigniter4/framework/system/bootstrap.php:145
PHP  4. CodeIgniter\Config\BaseService::getSharedInstance() /var/www/xyz.com/vendor/codeigniter4/framework/system/Config/Services.php:134
PHP  5. CodeIgniter\Config\Services::codeigniter() /var/www/xyz.com/vendor/codeigniter4/framework/system/Config/BaseService.php:189
PHP  6. config() /var/www/xyz.com/vendor/codeigniter4/framework/system/Config/Services.php:137
PHP  7. CodeIgniter\Config\Factories::config() /var/www/xyz.com/vendor/codeigniter4/framework/system/Common.php:198
PHP  8. CodeIgniter\Config\Factories::__callStatic() /var/www/xyz.com/vendor/codeigniter4/framework/system/Common.php:198



RE: Error: Use of undefined constant ENVIRONMENT - CI 4.1.5 - donpwinston - 11-21-2021

Line 110 of Factories.php is:
self::$instances[$options['component']][$class] = new $class(...$arguments);

I believe there is something messed up with your installation.


RE: Error: Use of undefined constant ENVIRONMENT - CI 4.1.5 - Mobostar - 11-22-2021

I did a fresh CI4 installation via Composer and that error disappeared.