1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

get cakephp build-in css compression to work

Since cakephp 1.3, build-in css compression has stopped working. at least for me. however, it’s very easy to get it working again.

Step 1:

grab csspp from here and put it in your vendor directory so it looks something like this (app/vendors/csspp/csspp.php)

Step 2:

in your core.php file in app/config, uncomment Configure::write(‘Asset.filter.css’, ‘css.php’);

Step 3:

in your css.php under app/webroot,  modify make_clean_css function so that it looks something like this

function make_clean_css($path, $name)
{
App::import('Vendor', 'csspp' . DS . 'csspp');
$data = file_get_contents($path);
$csspp = new csspp($name,'');
$output = $csspp->process();
$ratio = 100 - (round(strlen($output) / strlen($data), 3) * 100);
$output = " /* file: $name, ratio: $ratio% */ " . $output;

return $output;
}

and that should be it. if it doesnt work for some reason,

change  line 82 in your app/webroot/css.php to

if (file_exists($cachepath) && 0)

so you won’t be looking at cached file when u debug.

Share:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • MySpace
  • Reddit
  • RSS
  • Slashdot
  • StumbleUpon
  • Twitter
  • Yahoo! Bookmarks
Share your opinion! Post your thoughts.