Download the PHP package acelaya/zf2-acassets without Composer
On this page you can find all versions of the php package acelaya/zf2-acassets. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download acelaya/zf2-acassets
More information about acelaya/zf2-acassets
Files in acelaya/zf2-acassets
Package zf2-acassets
Short Description Assets management module for Zend Framework 2
License BSD
Homepage https://github.com/acelaya/ZF2-AcAssets
Informations about the package zf2-acassets
AcAssets
This module can be used to define assets (CSS / JS) in configuration files instead of defining them directly in a layout, injecting defined scripts and stylesheets in InlineScript, HeadScript and HeadLink.
This allows to take advantage of Zend Framework's configuration system, overriding global configurations with local configuration or even defining different configurations for each environment. Take a look at this advanced configuration tricks.
It only works with existing assets in public directory. It does not minify or concatenate assets. For this purpose, please look at other modules like AssetsManager or zf2-assetic-module.
Installation
Install composer in your project.
Define dependencies in your composer.json file
Install dependencies
After installing the module, copy vendor/acelaya/zf2-acassets/config/assets.global.php.dist
to config/autoload/assets.global.php
. This will provide an empty configuration file that will be explained later.
Finally enable the module in your application.config.php
file.
Usage
This module is very easy to use. You only need to setup your assets configuration. If the module is enabled it will inject all configured asstes automatically at DISPATCH and DIPATCH_ERROR.
Then, you only need to print the headScript, inlineScript and headLink in your layout or view. They will be fully configured.
If there is some configuration you need to do that is not supported by this module, you can already append other files and stylesheets to any element in a regular way.
Configuration
An example of a configuration file could be this.
The css
block wraps the stylesheets that will be included in the headLink element. The nested path
is used to define a base path that will be prepended to each defined stylesheet. It will be "/" if not defined.
The stylsheets
block is an array with all the stylsheets that need to be injected. It is an associative array to allow configuration overriding, but the key is just orientative. Each value has a name
property, which is the filename relative to the path
property. It can have an optional media
property.
The js
block wraps the files that will be included in headScript and inlineScript. It also has a nested path
with the basepath of the scripts.
Both inline
and head
are associative arrays with the files that should be injected in the layout. As in stylesheets
, the name
property is the filename relative to path
. It also has an options
property which is the third param used when calling the method appendFile
.
The scripts and stylesheets are appended in the order they are defined in css/stylesheets
, js/inline
and js/head
, but a priority
property can be defined in any of them to set the order in which they should be appended. It's 1 by default.
TODO
Look at the issues page to know what is planned to be included in the module.