Search code examples
cakephpcakephp-2.0yuiminifycakephp-2.2

Asset Compress Plugin for CakePHP not working


I'm having troubles to compress my Javascript files using Asset Compress Plugin for CakePHP 2.X. I'm currently using CakePHP 2.2.2 over IIS 7.

It tries to add the compressed js file but it doesn't exist:

<script type="text/javascript" src="/cakephp/cache_js/jquery-combined.v1379067166.js">
  • I have downloaded and placed the plugin under app/Plugin/AssetCompress/
  • I have dowloaded YUI build tool and placed the file contained in lib/yuicompressor/yuicompressor-2.4.2 in vendors/yuicompressor/
  • I have made the folder webroot/cache_js/ writable.

This is my asset_compress.ini:

[General]
cacheConfig = false

[js]
timestamp = true
path = WEBROOT/js/*
cachePath = WEBROOT/cache_js/
filters[] = YuiJs

[jquery-combined.js]
files[] = jquery.tipsy.js
files[] = web.js

And I am adding the plugin in bootstrap like this with debug mode set to 0:

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

CakePlugin::load('AssetCompress', array('bootstrap' => true));

Also, I'm loading it from the AppController:

var $helpers = array('AssetCompress.AssetCompress');

And using it on the layout template in this way:

echo $this->AssetCompress->script('jquery-combined');

The only error I'm getting on the error.log is the following one:

2013-09-13 14:16:10 Error: [MissingControllerException] Controller class CacheJsController could not be found. C:\inetpub\wwwroot\cakephp\app\webroot\index.php(92): Dispatcher-> dispatch(Object(CakeRequest), Object(CakeResponse)) C:\inetpub\wwwroot\cakephp\index.php(42): require('C:\inetpub\wwwr...') {main}

Any clue about what can be happening? Should I have Java SDK installed ? Am I picking the wrong .jar file from YUI?

Thanks.


Solution

  • Before you can set debug = 0 you need to use the CLI tool to build static versions of the assets. I'm pretty sure this is in the documentation.