GatorGuy023
GatorGuy023

Reputation: 297

CakePHP's DebugKit assets are not loading

Now I know there is a work around already for this were I can just copy the assets to the projects own webroot. And will probably just do that in a bit however . . .

I do want to know why I keep getting this issue. I was poking around in the AssetDispatcher code and placed some CakeLog::write() statements in there and when I call the page the dispatcher is only called once. Shouldn't it be called for each asset that is being requested? Is there another file that handles the dispatching of assets other than this class I can look at?

I have a fresh install of cakephp 2.5.5 and DebugKit 2.2.4

I followed the instructions in how to load the plugin and indeed the php code is seeing the plugin and tries to load it. It is just not being displayed properly because it can't find the css and js within the plugin.

I did some searching and found somethings stating that the order that the plugins are loaded and the order of the dispatchers withing the bootstrap.php file matters here. I am using a fresh install of cakephp here and that order is already present. DebugKit is loaded and then the dispatchers.

Mostly I could use some help in how to debug the dispatchers since this seems to be where the problem is. Never have had to touch these before. The cakebook gives general information on how to write your own, but I am more interested in the lifecycle here.

Or more like I am making this overly complicated and there is an even easier thing to do here to figure this out. Any information is appreciated.

I've included the relevent code on the initial setup of the DebugKit below in case I missed something simple or overlooked something I thought I had done.

app/Config/bootstrap.php

CakePlugin::load( 'DebugKit' );
Configure::write('Dispatcher.filters', array(
    'AssetDispatcher',
    'CacheDispatcher'
));

app/Controller/AppController.php

$components = array( 'DebugKit.Toolbar' );

app/View/Layout/default.ctp bottom of file

                        <p>
                            <?php echo $cakeVersion; ?>
                        </p>
                </div>
        </div>
</body>
</html>

These are the paths that cake is having trouble resolving

/debug_kit/css/debug_toolbar.css
/debug_kit/js/js_debug_toolbar.js
/debug_kit/image/cake.icon.png

These are the urls that cake is generating itself

Upvotes: 1

Views: 1594

Answers (2)

Zharfan Mazli
Zharfan Mazli

Reputation: 41

I have the same problem before when upgrading to the latest CakePHP. I solve it by adding the following codes in bootstrap.php:

Configure::write('Dispatcher.filters', array(
    'AssetDispatcher',
    'CacheDispatcher'
));

When upgrading to latest version, you need to also check whether there are changes in index.php and htaccess file.

Upvotes: 2

FelipeEduardo
FelipeEduardo

Reputation: 56

Here are the steps you follow:

  1. Install CakePHP and check installation.

  2. Download the latest DebugKit 2.2.1, which is compatible with Cake 2.4

  3. Copy the contents to the cake/plugins/DebugKit folder.

  4. Call CakePlugin::load('DebugKit'); in app/Config/bootstrap.php

  5. Include toolbar component by calling public $components = array('DebugKit.Toolbar'); within the class of AppController.php

  6. Set Configure::write('debug', 1); in app/Config/core.php

  7. Remove the 'sql_dump' element from my layout in app/View/Layouts/default.ctp

  8. Copy all contents (folders 'css', 'js', 'img') of app/Plugin/DebugKit/webroot/ in app/webroot/debug_kit/

Upvotes: 1

Related Questions