I installed Codeigniter 4.0.2 and did following changes:
1- CI_ENVIRONMENT = development
in.env file
2- SetEnv CI_ENVIRONMENT development
in .htaccess in public folder
3- Added $useKint = true;
in main index.php file in public folder
When I open at localhost, welcome page is rendered but no Debug Toolbar is rendered. Am I missing anything?
This fixed it for me:
# CI_ENVIRONMENT = production
and change to the value to development
app.baseURL
value to your app's base URL (this seems like the step you missed)I got this problem too for 3 days. Today I solve this problem by make /writable/debugbar/ to 777 (just for development)
chmod -R 777 [yourappname]/writable/debugbar/
hopefully this gives you and everyone solution
Here are some stuffs you can check with a fresh CI4 installation :
Make sure you have defined('CI_DEBUG') || define('CI_DEBUG', 1);
defined('CI_DEBUG') || define('CI_DEBUG', 1);
in your app/Config/Boot/development.php file
Try to launch your app with the command line php spark serve
so you can grab some informations about your app accessing the toolbar.
Make sure you have a variable named $globals
in app/Config/Filters.php with 'toolbar' as a value of the 'after' key and 'toolbar' being correctly mapped with the toolbar class into $aliases
public $aliases = [ 'csrf' => \CodeIgniter\Filters\CSRF::class, 'toolbar' => \CodeIgniter\Filters\DebugToolbar::class, 'honeypot' => \CodeIgniter\Filters\Honeypot::class ];
public $globals = [ 'before' => [ //'honeypot' // 'csrf', ], 'after' => [ 'toolbar', //'honeypot' ], ];
It can be some starting points, hope this helps.
Set the base url properly if you are not using PHP's built-in server
app/config/App.php
public $baseURL = 'http://localhost/path_to_CI/public';
正如文档所说,您需要“php spark serve”,因为调试栏会在 spark 设置中查找 localhost:8080。
在您的 env 文件中必须使用公共文件夹修改 baseurl
app.baseURL = 'http://localhost/your-app/public'
Today I've faced the same issue in my very first attempt to use CI4 (with XAMPP)... The only one change I've made on the CI4 framework was to rename the env file to .env and then I set CI_ENVIRONMENT = development in .env file
I've found 2 solutions:
Use the "php spark serve" command to start my project instead of XAMPP
Point $baseURL in app\Config\App.php to my project's public folder
Hope this helps! Best regards
Make sure to use HTTP protocol and not HTTP S .
On .env
file check the app.baseURL = 'http://localhost/'
and not app.baseURL = 'https://localhost'
.
Then, on the browser access it using http://
and not https://
.
In my case, the problem was in app.baseURL I did put where my proyect is compbase
-- app.baseURL = 'http://compbase'
and I changed it to
-- app.baseURL = 'http://compbase.test'
When you are using laragon
Just add following lines to app/config/filters.php
and its work like a charm
public $collectors = [
\CodeIgniter\Debug\Toolbar\Collectors\Timers::class,
\CodeIgniter\Debug\Toolbar\Collectors\Database::class,
\CodeIgniter\Debug\Toolbar\Collectors\Logs::class,
\CodeIgniter\Debug\Toolbar\Collectors\Views::class,
\CodeIgniter\Debug\Toolbar\Collectors\Cache::class,
\CodeIgniter\Debug\Toolbar\Collectors\Files::class,
\CodeIgniter\Debug\Toolbar\Collectors\Routes::class,
\CodeIgniter\Debug\Toolbar\Collectors\Events::class,
];
No need of do anything else as per Document
Check your code at App\Config\Filtes.php
.
Use this line of code:
public $aliases = [
'csrf' => CSRF::class,
'toolbar' => DebugToolbar::class,
'honeypot' => Honeypot::class,
];
Instead of this:
public $aliases = [
'csrf' => CodeIgniter\Filters\CSRF::class,
'toolbar' => CodeIgniter\Filters\DebugToolbar::class,
'honeypot' => CodeIgniter\Filters\Honeypot::class,
];
I was same issue with installing ci 4.1.5 and solved by this way:
make user .env file exist in project root folder.
rename env to .env
or create .env
in project root folder.
set development environment in .env
file
CI_ENVIRONMENT=development
set base url in .env
file
app.baseURL = 'http://localhost/project-root/public/'
I had the same problem It solved when I change directory "writeable/debugbar" to 777 (writeable)
CodeIgniter Debut icon will show at to bottom right if if correct.
It's working fine here in CI 4.2.6 and a heavily modified folder structure, writable
folder set as 775, on a public address too (so no need for spark serve). My issue was that $baseURL
was pointing to the address with http://
instead of https://
for a typo, so the Chrome inspector helped me out to track it down.
Changing that in App.php, it works like a charm.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.