Debug Toolbar in Codeigniter 4 not working
Asked Answered
V

17

5

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?

Venicevenin answered 24/3, 2020 at 13:37 Comment(1)
Yes you might be missing the step to install Kint and its friends... Your installation may not have the vendor folder, so you need to run "composer install".Norine
M
25

This fixed it for me:

  1. Rename env file to .env and open it
  2. Uncomment line # CI_ENVIRONMENT = production and change to the value to development
  3. Change the app.baseURL value to your app's base URL (this seems like the step you missed)
Meany answered 17/5, 2020 at 21:15 Comment(3)
This seems to be the one that worked for me. I have set the base URL wrong for some reasonLoriloria
Is there any way i can show debug to only certain role?Denote
I modified the app.baseURL on the fly (so had to reset it just at the end to still see the toolbar). Also best to just check the documentation: codeigniter.com/user_guide/testing/…Rich
M
9

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.

enter image description here

Click the icon you will be able to see debug bar like this. enter image description here

Marvamarve answered 24/3, 2020 at 15:43 Comment(2)
I know it should be there as per documentation, but i dont get any bar or logo :(Venicevenin
I had the same extact configuration what posted here. It's working fine. Take look at the writable/debugbar/debugbar_*.json file. Check whether any debug logs are wriiten in it.Marvamarve
D
7

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

Dougald answered 2/10, 2020 at 11:40 Comment(0)
S
4

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.

footer of welcome page

  • 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.

http info about 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.

Sialoid answered 31/3, 2020 at 9:37 Comment(0)
I
3

You need to "php spark serve" as the documentation say, because debugbar looks for localhost:8080 as in spark set on.

Inkhorn answered 10/6, 2020 at 18:39 Comment(0)
H
2

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';
Hephaestus answered 27/4, 2020 at 10:0 Comment(0)
H
1

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

Helminth answered 10/4, 2020 at 18:12 Comment(0)
P
1

in your env file must modify the baseurl with public folder
app.baseURL = 'http://localhost/your-app/public'

Plumbum answered 9/3, 2021 at 21:46 Comment(0)
A
1

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/'
Adam answered 21/11, 2021 at 8:42 Comment(0)
P
0

Make sure to use HTTP protocol and not HTTPS.

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://.

Physiological answered 2/9, 2020 at 13:27 Comment(0)
H
0

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

Hufuf answered 3/11, 2020 at 15:33 Comment(0)
K
0

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

Karrikarrie answered 26/3, 2021 at 6:20 Comment(0)
N
0

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,
    ];
Nabila answered 15/11, 2021 at 15:58 Comment(0)
L
0

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.

Loge answered 18/7, 2022 at 14:6 Comment(0)
A
0

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.

Ascus answered 15/9, 2022 at 19:47 Comment(0)
P
0

I've set app.baseURL = 'http://localhost/project-root/public/' but used http://127.0.0.1/project-root/public/ on my browser URL -> No toolbar. Change URL to http://localhost/project-root/public/ and toolbar appears

Poll answered 28/10, 2023 at 16:14 Comment(0)
N
0

In your .env file, update the following variables

CI_ENVIRONMENT = development

app.baseURL = 'http://localhost/<name of your project>/'

app.forceGlobalSecureRequests = false

Make sure your project is running in port 8080

Nashbar answered 10/3 at 0:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.