Skip to content

gourmet/assetic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Assetic for CakePHP

Built to seamlessly integrate Assetic with CakePHP.

This is an unstable repository and should be treated as an alpha.

UPDATE: Now that @mark_story has released markstory/asset_compress, I have stopped actively developing this plugin.

Install

composer require gourmet/assetic:*

or by adding this package to your project's composer.json:

"require": {
	"gourmet/assetic": "*"
}

Usage

The AsseticHelper methods work somewhat like their HtmlHelper counter-parts but with some added options.

The methods are:

  • css($path, $options)
  • image($path, $options)
  • script(_$url, $options)

The added $options keys are:

  • debug: boolean Defaults to app's configuration debug value.
  • output: string Name of the Assetic created asset.
  • filters: array|string Filter(s) to use. Defaults to the configured filters for the asset type (css, image, js).

The $path passed to css() and the $url passed to script can be passed as a string or as an associative array (see examples below).

Examples

echo $this->Assetic->css('cake.generic', ['debug' => false, 'filters' => 'cssmin']);
echo $this->Assetic->css(['cake.generic' => 'cssmin'], ['debug' => false]);
echo $this->Assetic->css('cake.generic');

All the above examples will have the same result, including the minified version of cake.generic.css. For the last example, it is assumed that the value of the Assetic.cssFilters configuration contains at least the cssmin key.

$this->Assetic->css('cake.generic', ['filters' => 'cssmin,?uglify']);

In the above example, when in debug mode, only the cssmin filter will be run.