Whoops! We seem to have hit a snag. Please try again later.
Codeigniter 4 shows an error when I run the CI4 application, Ho
In your CI4 project root, create a file named .env
. It should be in the same directory as system, app e.t.c
Then, add this CI_ENVIRONMENT = development
I got the answer for this query; just follow these steps:
From the command line, at your project root just hit this
php spark serve
Then hit this on your browser http://localhost:8080/
Enjoy your Latest CI.
Assume that your root folder of your CI4 project is rootproject
.
Edit rootproject/.env
file.
On line 17 change from:
# CI_ENVIRONMENT = production
to:
CI_ENVIRONMENT = development
Save it.
Refresh your browser that pointing to your CI4 project. It should give you many error messages.
If there is something written as CacheException
, than your cache folders are not writable.
Make it writable;
Ubuntu:
chown -Rv www-data rootproject/writable
CentOS:
chown -Rv apache rootproject/writable
Easy way:
chmod 777 -Rv rootproject/writable
After installing CodeIgniter 4 when you run the app then you will get an error like this
To know the error go to the app/Config/Boot/production.php and set display_errors to 1 as below
ini_set('display_errors', '1');
Now, you will see the actual error below
Nothing to worry about it. The app needs permission. Assign the permission like as below
sudo chmod -R 777 project_name
For those using XAMPP in MacOS:
You don't need to change the ownership of the writable directory. You only need to change permission to entire directory:
chmod -R 777 writable
This work for me try it Go to app directory then to boot directory you will see production.php file.
That is:
app => Config => Boot => production.php
Change the ini_set('display_errors', '0')
to ini_set('display_errors', '1')
.
Warning: When in production change back to initial ini_set('display_errors', '0')
Or
you can rename your file env
in your project directory to .env
after that open it and edit.
Search for # CI_ENVIRONMENT = production
remove #
and change production
to development