zfcampus / zf-asset-manager
Composer plugin for copying module assets into application document roots.
Installs: 451 577
Dependents: 3
Suggesters: 2
Security: 0
Stars: 11
Watchers: 7
Forks: 6
Open Issues: 0
Type:composer-plugin
Requires
- php: ^5.6 || ^7.0
- composer-plugin-api: ^1.1
Requires (Dev)
- composer/composer: >=1.0.0-alpha10
- mikey179/vfsstream: ^1.6
- phpunit/phpunit: ^5.7.23 || ^6.4.3
- squizlabs/php_codesniffer: ^2.6.2
README
Repository abandoned 2019-12-31
This repository has moved to laminas-api-tools/api-tools-asset-manager.
zf-asset-manager is a composer plugin that will copy configured web-accessible assets into the public document root of your Zend Framework application. It uses the configuration format of rwoverdijk/AssetManager, and specifically the subset:
'asset_manager' => [ 'resolver_configs' => [ 'paths' => [ /* paths containing asset directories */ ], ], ],
Each configured path is iterated, and every path under it is then copied into the public tree.
Installation
$ composer require --dev zfcampus/zf-asset-manager
Recommended for development
We recommend usage of this module primarily for development purposes. In most cases, assets from third-party modules should be overridden with project-specific assets when preparing for production. To emphasize this, the assets are excluded from your git repository by default. (You may add them manually later, as explained below.)
Example
As an example, given the following directory structure inside a package:
./
- asset/
- README.md
- gruntfile.js
- package.json
- zf-apigility/
- css/
- bootstrap.min.css
- img/
- logo.png
- js/
- bootstrap.min.js
- jquery.min.js
- zf-apigility-welcome/
- css/
- main.min.css
- img/
- ag-hero.png
- config/
- module.config.php
where module.config.php
defines (minimally) the following:
return [ 'asset_manager' => [ 'resolver_configs' => [ 'paths' => [ __DIR__ . '/../asset/' ], ], ], ]
When you install the package, the asset manager will copy each of the
asset/zf-apigility/
and asset/zf-apigility-welcome/
trees to the project's
public/
path. The individual files asset/README.md
, asset/gruntfile.js
, and
asset/package.json
are omitted from the install, as they are not directories.
Additionally, during installation, the plugin adds a .gitignore
file to the
public/
path, listing each of the new directories:
# public/.gitignore
zf-apigility/
zf-apigility-welcome/
After installation, you may access any of the assets installed relative to the public root.
Uninstallation
When you remove the module, the plugin will:
- Remove any asset trees configured for the module from the public tree.
- Remove the
.gitignore
entries associated with those asset trees from thepublic/.gitignore
file.
Keeping assets
Assets are marked by Git to ignore by default. The intention of this module is primarily for development purposes; it was developed to allow installation of assets related to the Apiglity admin UI, welcome screen, and documentation, most of which are relevant in development mode only.
However, if you wish to keep the assets in your public tree, you can do so as follows:
- Edit the
public/.gitignore
file to remove the entry for the asset tree(s) you wish to keep. - Add the asset tree(s) to your repository (
git add public/{tree}
).
Removing the entry from public/.gitignore
is enough to prevent the uninstaller
from removing the assets when you remove a module.