4

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?

yivi
  • 42,438
  • 18
  • 116
  • 138
MyO
  • 413
  • 1
  • 8
  • 19
  • 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". – TimBrownlaw Apr 11 '20 at 07:06

15 Answers15

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)
β.εηοιτ.βε
  • 33,893
  • 13
  • 69
  • 83
MicroWise
  • 416
  • 3
  • 5
  • 2
    This seems to be the one that worked for me. I have set the base URL wrong for some reason – rksh Sep 14 '20 at 17:38
  • Is there any way i can show debug to only certain role? – Sohan Arafat Oct 16 '21 at 23:53
  • 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: https://codeigniter.com/user_guide/testing/debugging.html#enabling-the-toolbar – Aldo Jun 14 '23 at 10:29
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

Thiru A P
  • 151
  • 1
  • 3
  • I know it should be there as per documentation, but i dont get any bar or logo :( – MyO Mar 24 '20 at 16:14
  • 1
    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. – Thiru A P Mar 25 '20 at 04:47
5

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

3

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.

ViLar
  • 1,054
  • 10
  • 18
3

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

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';
Dum
  • 1,431
  • 2
  • 9
  • 23
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

1

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

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

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

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

TarangP
  • 2,711
  • 5
  • 20
  • 41
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,
    ];
Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
erick
  • 1
0

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

Jay
  • 41
  • 3
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.

cdsaenz
  • 520
  • 1
  • 10
  • 15