Debug Toolbar in Codeigniter 4 not working

走远了吗. 提交于 2020-04-16 02:53:05

问题


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?


回答1:


The debug toolbar will be there in bottom right cornor with a codigniter code logo

  1. Click that in order to open the debug bar.

Click the icon you will be able to see debug bar like this.




回答2:


Here are some stuffs you can check with a fresh CI4 installation :

  • Your environment is really on development (you can check it in the footer of your welcome page). If not, be sure to set CI_ENVIRONMENT = development in your .env. Watch out because fresh CI4 doesn't come with a .env file but with a env file. Be sure to rename it.

  • Make sure you have 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.




回答3:


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



来源:https://stackoverflow.com/questions/60832190/debug-toolbar-in-codeigniter-4-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!