Skip to content

Bug: Fatal error: Uncaught Error: Undefined constant "ENVIRONMENT" in /var/www/html/MyApp/system/Common.php:777 #8945

@DaveInga

Description

@DaveInga

PHP Version

8.2

CodeIgniter4 Version

4.4.8

CodeIgniter4 Installation Method

Manual (zip or tar.gz)

Which operating systems have you tested for this bug?

macOS, Linux

Which server did you use?

apache

Database

MariaDB 10.6

What happened?

When running docker compose, I have an entrypoint script that calls "php spark migrate" to migrate tables to MariaDB. The error that appears in my terminal output from "docker compose up --build" is "Could not open input file: spark".

Steps to Reproduce

To debug the error, I entered the container with "docker run -it --entrypoint /bin/bash " and changed directory to /var/www/html (where the spark shell script has been copied to) and verified that the permissions were runnable (-rwxr-xr-x 1 www-data www-data 2815 Jun 10 00:42 spark). I then ran "php spark" and got the error.

root@297c44e85927:/var/www/html# php spark
This "system/bootstrap.php" is no longer used. If you are seeing this error message,
the upgrade is not complete. Please refer to the upgrade guide and complete the upgrade.
See https://codeigniter4.github.io/userguide/installation/upgrade_450.html

Fatal error: Uncaught Error: Undefined constant "ENVIRONMENT" in /var/www/html/Tooths/system/Common.php:777
Stack trace:
#0 /var/www/html/Tooths/system/Debug/Exceptions.php(458): log_message('warning', '[DEPRECATED] {m...', Array)
#1 /var/www/html/Tooths/system/Debug/Exceptions.php(216): CodeIgniter\Debug\Exceptions->handleDeprecationError('Creation of dyn...', '/var/www/html/T...', 218)
#2 /var/www/html/Tooths/app/Config/App.php(218): CodeIgniter\Debug\Exceptions->errorHandler(8192, 'Creation of dyn...', '/var/www/html/T...', 218)
#3 /var/www/html/Tooths/system/Config/Factories.php(235): Config\App->__construct()
#4 /var/www/html/Tooths/system/Config/Factories.php(169): CodeIgniter\Config\Factories::createInstance('config', 'Config\\App', Array)
#5 /var/www/html/Tooths/system/Config/Factories.php(188): CodeIgniter\Config\Factories::__callStatic('config', Array)
#6 /var/www/html/Tooths/system/Common.php(207): CodeIgniter\Config\Factories::get('config', 'Config\\App')
#7 /var/www/html/Tooths/system/Config/Services.php(564): config('Config\\App')
#8 /var/www/html/Tooths/system/Config/BaseService.php(320): CodeIgniter\Config\Services::incomingrequest(NULL, false)
#9 /var/www/html/Tooths/system/Config/Services.php(526): CodeIgniter\Config\BaseService::__callStatic('incomingrequest', Array)
#10 /var/www/html/Tooths/system/Config/BaseService.php(311): CodeIgniter\Config\Services::request(NULL, false)
#11 /var/www/html/Tooths/system/Config/BaseService.php(250): CodeIgniter\Config\BaseService::__callStatic('request', Array)
#12 /var/www/html/Tooths/system/Config/Services.php(522): CodeIgniter\Config\BaseService::getSharedInstance('request', NULL)
#13 /var/www/html/Tooths/system/Config/BaseService.php(320): CodeIgniter\Config\Services::request()
#14 /var/www/html/Tooths/system/Debug/Exceptions.php(129): CodeIgniter\Config\BaseService::__callStatic('request', Array)
#15 [internal function]: CodeIgniter\Debug\Exceptions->exceptionHandler(Object(Error))
#16 {main}
  thrown in /var/www/html/Tooths/system/Common.php on line 777

Fatal error: Uncaught Error: Undefined constant "ENVIRONMENT" in /var/www/html/Tooths/system/Common.php:777
Stack trace:
#0 /var/www/html/Tooths/system/Debug/Exceptions.php(458): log_message('warning', '[DEPRECATED] {m...', Array)
#1 /var/www/html/Tooths/system/Debug/Exceptions.php(216): CodeIgniter\Debug\Exceptions->handleDeprecationError('Creation of dyn...', '/var/www/html/T...', 218)
#2 /var/www/html/Tooths/app/Config/App.php(218): CodeIgniter\Debug\Exceptions->errorHandler(8192, 'Creation of dyn...', '/var/www/html/T...', 218)
#3 /var/www/html/Tooths/system/Config/Factories.php(235): Config\App->__construct()
#4 /var/www/html/Tooths/system/Config/Factories.php(169): CodeIgniter\Config\Factories::createInstance('config', 'Config\\App', Array)
#5 /var/www/html/Tooths/system/Config/Factories.php(188): CodeIgniter\Config\Factories::__callStatic('config', Array)
#6 /var/www/html/Tooths/system/Common.php(207): CodeIgniter\Config\Factories::get('config', 'Config\\App')
#7 /var/www/html/Tooths/system/Config/Services.php(564): config('Config\\App')
#8 /var/www/html/Tooths/system/Config/BaseService.php(311): CodeIgniter\Config\Services::incomingrequest(NULL, false)
#9 /var/www/html/Tooths/system/Config/Services.php(526): CodeIgniter\Config\BaseService::__callStatic('incomingrequest', Array)
#10 /var/www/html/Tooths/system/Config/BaseService.php(311): CodeIgniter\Config\Services::request(NULL, false)
#11 /var/www/html/Tooths/system/Config/BaseService.php(250): CodeIgniter\Config\BaseService::__callStatic('request', Array)
#12 /var/www/html/Tooths/system/Config/Services.php(522): CodeIgniter\Config\BaseService::getSharedInstance('request', NULL)
#13 /var/www/html/Tooths/system/Config/BaseService.php(311): CodeIgniter\Config\Services::request()
#14 /var/www/html/Tooths/system/Debug/Exceptions.php(129): CodeIgniter\Config\BaseService::__callStatic('request', Array)
#15 /var/www/html/Tooths/system/Debug/Exceptions.php(252): CodeIgniter\Debug\Exceptions->exceptionHandler(Object(ErrorException))
#16 [internal function]: CodeIgniter\Debug\Exceptions->shutdownHandler()
#17 {main}
  thrown in /var/www/html/Tooths/system/Common.php on line 777

Expected Output

I expected spark to run my migrations to the database defined by my environment variables. I use different environment variables for local/staging/production databases.

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions