问题
Whoops! We seem to have hit a snag. Please try again later.
Codeigniter 4 shows an error when I run the CI4 application, How I resolve?
Changes:
public $baseURL = 'http://ci.local';
public $baseURL = 'http://localhost:8080';
public $indexPage = '';
回答1:
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
回答2:
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
回答3:
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
回答4:
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
回答5:
You're running in the production environment and need to change it to a Development or Testing environment to see the error messages within the browser.
There are a few ways to do this, but adding:
SetEnv CI_ENVIRONMENT development
To the Apache httpd.config file is what worked for me.
_t
回答6:
Not sure what the desired answer is, but:
- If you are asking to see what is the actual error is - either change your environment to testing/development (as suggested so far) or you can check your logs - writable/logs/log-.php
- If you wish to solve the error, we will need more information, like have you setup virtual hosts, have you change .htaccess file in public folder, etc. Otherwise we will be most likely betting (I bet it's virtual hosts).
In any case, a copy of the displayed error (after changing evnironment) or log file will be useful.
回答7:
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.
回答8:
I had the same problem, I have a simple solution for Mac. - in the project folder, go to 'writable' - select all the folders contained and click on 'get information' - go share and permissions - in 'everyone' select 'read and write' That's it! refresh the page
回答9:
In Root folder change: env to .env
Change
# CI_ENVIRONMENT = production
toCI_ENVIRONMENT = development
(ensure it is uncommented)Your error may be related to the knit.php file.
Go to System/Third Party and change: knit.php to Knit.php (Capital)Reload.
回答10:
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
回答11:
You can check logs file on writable/logs find error information, If your logs information like :
CRITICAL - 2020-04-19 17:44:55 --> Invalid file: template/header.php
#0 F:\xampp\htdocs\ppdb\vendor\codeigniter4\framework\system\View\View.php(224): CodeIgniter\Exceptions\FrameworkException::forInvalidFile('template/header...')
And go fix your error, in my case i am wrong typed name on controller file
来源:https://stackoverflow.com/questions/57852169/whoops-we-seem-to-have-hit-a-snag-please-try-again-later