simple-php / composer-assets-plugin
Composer plugin for installing of assets.
Installs: 7
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 5
Type:composer-plugin
pkg:composer/simple-php/composer-assets-plugin
Requires
- php: >=5.4.0
- composer-plugin-api: ^1.0
README
Composer plugin for installing assets.
Installation
Use Composer:
composer require simple-php/composer-assets-plugin
Library requires PHP 5.4.0 or later.
Commands
composer refresh-assets- refresh files inassetsdirectory
Assets configuration
Packages
assets-filesin sectionextratrue- symlinks whole package directory- file path - symlinks one file or directory
- list of file paths - symlinks files/directories
Example:
{
"extra": {
"assets-files": [
"static/plugin.js",
"static/plugin.css",
"static/icons.png"
]
}
}
static/plugin.js- symlinks file toassets/org/package/plugin.jsstatic/plugin.css- symlinks file toassets/org/package/plugin.cssstatic/icons.png- symlinks file toassets/org/package/icons.png
By default, assets files stored in assets-dir specified in root package composer config. Package name used as path, for example, for package
package-owner/package-name following path will be used by default: assets-dir/package-owner/package-name.
You can specify different default path for package with option assets-target in section extra:
assets-targettarget path to copy assets files, optional- if relative path specified it will be related to
assets-dir - if absolute path specified it will be related to parent of
vendor-dir
- if relative path specified it will be related to
Example:
{
"extra": {
"assets-target": "package1",
"assets-files": [
... some assets files ...
]
}
}
Relative path specified, assets files will be copied to `assets-dir`/package1
``` json
{
"extra": {
"assets-target": "/templates/default/js",
"assets-files": [
... some assets files ...
]
}
}
Absolute path specified, assets files will be copied to `project-dir`/templates/default/js, where `project-dir` is parent directory of composer `vendor-dir`
IMPORTANT: Assets files will not be cleaned on package update or removing, if default absolute path for `assets-target` is used.
If you need automatic cleanup of assets files for this package you must redefine `assets-target` for this package in root package config.
### Root package
* `assets-dir` - directory for installing of assets, default `assets`, relative to `vendor-dir`
* `assets-directory` - alias for `assets-dir`
* `assets-files` - list of asset files in incompatible packages, it overrides `assets-files` from installed packages
* `assets-strategy` - install strategy for assets
* `auto` - select strategy by platform (default value)
* `copy` - copy all assets, default strategy on Windows
* `symlink` - create relative symlinks, default strategy on non-Windows platforms
* `assets-target` - target directory for specific packages, relative to `vendor-dir`, must be out of `assets-dir`
Example:
``` json
{
"config": {
"assets-dir": "public",
"assets-files": {
"org/package": true,
"org/package2": "js/calendar.js",
"org/package3": [
"static/plugin.js",
"static/plugin.css",
"static/icons.png"
]
},
"assets-target": {
"ckeditor/ckeditor": "admin/wysiwyg"
}
}
}
org/package- symlinks whole package directory topublic/org/packageorg/package2- symlinks filejs/calendar.jstopublic/org/package2/calendar.jsorg/package3static/plugin.js- symlinks file topublic/org/package3/plugin.jsstatic/plugin.css- symlinks file topublic/org/package3/plugin.cssstatic/icons.png- symlinks file topublic/org/package3/icons.png
ckeditor/ckeditor- symlinks files toadmin/wysiwyg
Default mapping
Plugin provides default mapping for selected incompatible packages. You can override this mapping in your composer.json.
List of packages with default mapping:
ckeditor/ckeditorcomponents/jquerynette/formso5/grido
Where find supported packages?
Some libraries and packages support Composer by default. For other exists shim-repositories:
Always you can search packages on Packagist.
License: New BSD License
Author: Jan Pecha, https://www.janpecha.cz/