Download the PHP package assetic/framework without Composer
On this page you can find all versions of the php package assetic/framework. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download assetic/framework
More information about assetic/framework
Files in assetic/framework
Package framework
Short Description Asset Management for PHP
License MIT
Homepage https://github.com/assetic-php/assetic
Informations about the package framework
Assetic
Assetic is an asset management framework for PHP maintained by the Winter CMS team.
Assets
An Assetic asset is something with filterable content that can be loaded and dumped. An asset also includes metadata, some of which can be manipulated and some of which is immutable.
Property | Accessor | Mutator |
---|---|---|
content | getContent | setContent |
mtime | getLastModified | n/a |
source root | getSourceRoot | n/a |
source path | getSourcePath | n/a |
target path | getTargetPath | setTargetPath |
The "target path" property denotes where an asset (or an collection of assets) should be dumped.
Filters
Filters can be applied to manipulate assets.
The filters applied to the collection will cascade to each asset leaf if you iterate over it.
The core provides the following filters in the Assetic\Filter
namespace:
CoffeeScriptFilter
: compiles CoffeeScript into JavascriptCssImportFilter
: inlines imported stylesheetsCSSMinFilter
: minifies CSSCssRewriteFilter
: fixes relative URLs in CSS assets when moving to a new URLGoogleClosure\CompilerApiFilter
: compiles Javascript using the Google Closure Compiler APIHandlebarsFilter
: compiles Handlebars templates into JavascriptJavaScriptMinifierFilter
: minifies JavascriptJpegoptimFilter
: optimize your JPEGsJpegtranFilter
: optimize your JPEGsLessFilter
: parses LESS into CSS (using less.js with node.js)LessphpFilter
: parses LESS into CSS (using lessphp)OptiPngFilter
: optimize your PNGsPackerFilter
: compresses Javascript using Dean Edwards's PackerPhpCssEmbedFilter
: embeds image data in your stylesheetReactJsxFilter
: compiles React JSX into JavaScriptScssphpFilter
: parses SCSS into CSSSeparatorFilter
: inserts a separator between assets to prevent merge failuresStylesheetMinifyFilter
: compresses stylesheet CSS filesStylusFilter
: parses STYL into CSSTailwindCssFilter
: builds a Tailwind CSS stylesheet using the Tailwind CSS standalone CLI utilityTypeScriptFilter
: parses TypeScript into JavascriptUglifyCssFilter
: minifies CSSUglifyJs2Filter
: minifies JavascriptUglifyJs3Filter
: minifies Javascript
Asset Manager
An asset manager is provided for organizing assets.
The asset manager can also be used to reference assets to avoid duplication.
Filter Manager
A filter manager is also provided for organizing filters.
Asset Factory
If you'd rather not create all these objects by hand, you can use the asset factory, which will do most of the work for you.
The AssetFactory
is constructed with a root directory which is used as the base directory for relative asset paths.
Prefixing a filter name with a question mark, as cssmin
is here, will cause
that filter to be omitted when the factory is in debug mode.
You can also register Workers on the factory and all assets created
by it will be passed to the worker's process()
method before being returned. See Cache Busting below for an example.
Dumping Assets to static files
You can dump all the assets an AssetManager holds to files in a directory. This will probably be below your webserver's document root so the files can be served statically.
This will make use of the assets' target path.
Cache Busting
If you serve your assets from static files as just described, you can use the CacheBustingWorker to rewrite the target paths for assets. It will insert an identifier before the filename extension that is unique for a particular version of the asset.
This identifier is based on the modification time of the asset and will also take depended-on assets into consideration if the applied filters support it.
Internal caching
A simple caching mechanism is provided to avoid unnecessary work.
Twig
To use the Assetic Twig extension you must register it to your Twig environment:
Once in place, the extension exposes a stylesheets and a javascripts tag with a syntax similar to what the asset factory uses:
This example will render one link
element on the page that includes a URL
where the filtered asset can be found.
When the extension is in debug mode, this same tag will render multiple link
elements, one for each asset referenced by the css/src/*.sass
glob. The
specified filters will still be applied, unless they are marked as optional
using the ?
prefix.
This behavior can also be triggered by setting a debug
attribute on the tag:
These assets need to be written to the web directory so these URLs don't return 404 errors.
Assetic is based on the Python webassets library (available on GitHub).
All versions of framework with dependencies
ext-curl Version *
ext-json Version *
ext-simplexml Version *
symfony/process Version ^3.4 || ^4.0 || ^5.0 || ^6.0 || ^7.0
symfony/deprecation-contracts Version ^2.2.0 || ^3.0