PHPackages                             andreinocenti/cakephp-inocenti\_shrink - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. andreinocenti/cakephp-inocenti\_shrink

ActiveCakephp-plugin

andreinocenti/cakephp-inocenti\_shrink
======================================

Compiles, combines, and minifies javascript, coffee, less, scss, and css

3.0.7.2(7y ago)022MITPHPPHP &gt;=5.4.16

Since Mar 29Pushed 7y agoCompare

[ Source](https://github.com/andreinocenti/cakephp-inocenti_shrink)[ Packagist](https://packagist.org/packages/andreinocenti/cakephp-inocenti_shrink)[ Docs](https://github.com/andreinocenti/cakephp-inocenti_shrink)[ RSS](/packages/andreinocenti-cakephp-inocenti-shrink/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (3)Dependencies (7)Versions (13)Used By (0)

Shrink CakePHP Plugin
=====================

[](#shrink-cakephp-plugin)

About
-----

[](#about)

- Author: [Trent Richardson](http://trentrichardson.com)
- Twitter: [@practicalweb](http://twitter.com/practicalweb)

The Shrink plugin compiles, combines, and minifies javascript and css. It currently has support for native javascript and css, Less (php and node versions), Sass (php and ruby versions), CoffeeScript, and TypeScript.

Shrink is a minimal configuration plugin. For a super powerful, configurable asset minifier look into [Mark Story's asset\_compress](https://github.com/markstory/asset_compress) instead.

Installation
------------

[](#installation)

This version is for CakePHP 3, for other versions of CakePHP check the branches on Github.

It is recommended to use composer to install: `"trentrichardson/cakephp-shrink": "~3.0"`. Then enable your plugin in bootstrap.php `Plugin::load('Shrink');` or `Plugin::loadAll();`.

You can also manually download Shrink and place into app/Plugin folder

Enable the plugin in bootstrap.php with `Plugin::load('Shrink',['autoload'=>true]);` or `Plugin::loadAll();`. When manually installing you need to set the autoload flag to true.

Add "Shrink.Shrink" to your `$helpers` property in your controller. Likely AppController.php.

Usage
-----

[](#usage)

You use Shrink in the same way you already use the Html helper for js and css. The slight differences are that you must include the file extension (since you can now process less, sass, coffee), and the parameters following the files.

```
/**
* Adds a css file to the file queue
* @param array/string files - string name of a file or array containing multiple string of files
* @param bool immediate - true to immediately process and print the file, false to merge with others
* @param string how - 'link' to print , 'embed' to use ...css code...
* @return string - when $immediate=true the tag will be printed, "" otherwise
*/
public function css($files, $immediate=false, $how='link')

/**
* Adds a js file to the file queue
* @param array/string files - string name of a file or array containing multiple string of files
* @param bool immediate - true to immediately process and print the file, false to merge with others
* @param string how - 'link' for , 'async' for , 'embed' for ...js code...
* @return string - when $immediate=true the tag will be printed, "" otherwise
*/
public function js($files, $immediate=false, $how='link')

/**
* Processes/minify/combines queued files of the requested type.
* @param string type - 'js' or 'css'. This should be the end result type
* @param string how - 'link' for , 'async' for , 'embed' for ...js code...
* @param array files - string name of a file or array containing multiple string of files
* @return string - the  or
*/
$this->Shrink->fetch($type, $how='link')
```

Lets say you have a layout, and a view in the users controller. The view might have at the top:

```
