2017 © Pedro Peláez
 

cakephp-plugin cakephp-assets

Assets plugin for CakePHP

image

mirko-pagliai/cakephp-assets

Assets plugin for CakePHP

  • Monday, July 30, 2018
  • by mirko-pagliai
  • Repository
  • 1 Watchers
  • 0 Stars
  • 877 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 18 Versions
  • 643 % Grown

The README.md

cakephp-assets plugin

Software License CI codecov Codacy Badge CodeFactor, (*1)

cakephp-assets is a CakePHP plugin to allows you to handle and generate assets., (*2)

It uses matthiasmullie/minify and provides a convenient helper that allows you to combine multiple asset files into one single compressed file., (*3)

Did you like this plugin? Its development requires a lot of time for me. Please consider the possibility of making a donation: even a coffee is enough! Thank you., (*4)

Make a donation, (*5)


Installation

You can install the plugin via composer:, (*6)

$ composer require --prefer-dist mirko-pagliai/cakephp-assets

Then you have to load the plugin. For more information on how to load the plugin, please refer to the Cookbook., (*7)

Simply, you can execute the shell command to enable the plugin:, (*8)

bin/cake plugin load Assets

This would update your application's bootstrap method., (*9)

By default, the plugin uses the APP/tmp/assets directory to save the asset files. So you have to create the directory and make it writable:, (*10)

$ mkdir tmp/assets && chmod 775 tmp/assets

If you want to use a different directory, read the Configuration section., (*11)

Installation on older CakePHP and PHP versions

Recent packages and the master branch require at least CakePHP 5.0 and PHP 8.1 and the current development of the code is based on these and later versions of CakePHP and PHP. However, there are still some branches compatible with previous versions of CakePHP and PHP., (*12)

For PHP 7.2 and CakePHP 4 or later

The cakephp4 branch requires at least PHP >=7.2 and CakePHP ^4.0., (*13)

In this case, you can install the package as well:, (*14)

$ composer require --prefer-dist mirko-pagliai/cakephp-assets:dev-cakephp4

Note that the cakephp4 branch will no longer be updated as of January 5, 2024, except for security patches, and it matches the 1.5.13 version., (*15)

For PHP 5.6 and CakePHP 3 or later

The cakephp3 branch requires at least PHP 5.6 and CakePHP 3., (*16)

In this case, you can install the package as well:, (*17)

$ composer require --prefer-dist mirko-pagliai/cakephp-assets:dev-cakephp3

Note that the cakephp3 branch will no longer be updated as of April 27, 2021, except for security patches, and it matches the 1.5.4 version., (*18)

Configuration

The plugin uses some configuration parameters and you can set them using the \Cake\Core\Configure class, before loading the plugin., (*19)

For example, you can do this at the bottom of the file APP/config/app.php of your application., (*20)

Configuration values

Configure::write('Assets.force', false);

Setting Assets.force to true, the assets will be used even if debugging is enabled., (*21)

Configure::write('Assets.target', TMP . 'assets');

Setting Assets.target, you can use another directory where the plugin will generate the assets., (*22)

How to use

You have to use only the AssetHelper. This helper provides css() and script() methods, similar to the methods provided by the HtmlHelper., (*23)

The syntax is the same, you just have to change the name helper. Example for AssetHelper::css()., (*24)

echo $this->Asset->css(['one.css', 'two.css']);

This will combine and compress one.css and two.css files, creating a unique asset file, and will create a link element for CSS stylesheets, as does the method provided by the HtmlHelper., (*25)

The same also applies to the AssetHelper::script() method., (*26)

Refer to our API., (*27)

Versioning

For transparency and insight into our release cycle and to maintain backward compatibility, cakephp-assets will be maintained under the Semantic Versioning guidelines., (*28)

The Versions

30/07 2018
26/12 2016

1.1.2

1.1.2.0 https://github.com/mirko-pagliai/assets

Assets plugin for CakePHP

  Sources   Download

AGPL

The Requires

 

The Development Requires

by Mirko Pagliai

25/09 2016

1.1.1

1.1.1.0 https://github.com/mirko-pagliai/assets

Assets plugin for CakePHP

  Sources   Download

AGPL

The Requires

 

The Development Requires

by Mirko Pagliai

22/09 2016

1.1.0

1.1.0.0 https://github.com/mirko-pagliai/assets

Assets plugin for CakePHP

  Sources   Download

AGPL

The Requires

 

The Development Requires

by Mirko Pagliai

02/04 2016

1.0.1

1.0.1.0 https://github.com/mirko-pagliai/assets

Assets plugin for CakePHP

  Sources   Download

AGPL

The Requires

 

by Mirko Pagliai

06/03 2016

1.0.0

1.0.0.0 https://github.com/mirko-pagliai/assets

Assets plugin for CakePHP

  Sources   Download

AGPL

The Requires

 

by Mirko Pagliai