laradic / assets
Laravel 5 Asset Manager. Fully featured, flexible, extendable and toroughly tested and documented.
Installs: 31
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/laradic/assets
Requires
- php: >=5.5.9
- kriswallsmith/assetic: ~1.2
- laradic/dependency-sorter: ~1.0
- laradic/filesystem: ~1.0
- laradic/support: ~1.0
Requires (Dev)
- laradic/testing: ~1.0.1
- leafo/lessphp: ^0.3.7
- leafo/scssphp: ~0.1
- meenie/javascript-packer: ^1.1
- mockery/mockery: 0.9.*
- mrclay/minify: <2.3
- natxet/cssmin: 3.0.4
- patchwork/jsqueeze: ~1.0|~2.0
- phpunit/phpunit: ~4.8 || ^5.6
- ptachoire/cssembed: ~1.0
- twig/twig: ~1.23|~2.0
This package is not auto-updated.
Last update: 2025-10-26 08:53:49 UTC
README
Laradic Assets is a package for the Laravel 5 framework. It's made for Laravel 5.4+ and PHP 7.0+ .
The package follows the FIG standards PSR-1, PSR-2, and PSR-4 to ensure a high level of interoperability between shared PHP code.
Installation
composer require laradic/assets "~1.0"
Alternatively, for some of the Assetic filters to work you might need one of the following:
{
"leafo/lessphp": "^0.3.7",
"leafo/scssphp": "~0.1",
"meenie/javascript-packer": "^1.1",
"mrclay/minify": "<2.3",
"natxet/cssmin": "3.0.4",
"patchwork/jsqueeze": "~1.0|~2.0",
"ptachoire/cssembed": "~1.0",
"twig/twig": "~1.23|~2.0"
}
Documentation
For the full documenation, check out the Laradic Assets package documenatation.
Quick glance
The laradic/assets package is a Laravel 5 asset manager. It uses Assetic's filters in order to provide high functionality.
It provides a convienient way to handle your assets.
Overview
- A single
Assetcan be defined and compiled - Compiling will run all configured filters on the asset and write the result to the
cache_path. Returns an instance ofCompiler\Compiled Assets can beGrouped insideAreas. You could considerAreato be a 'group of groups'. You could for example createpackage-name/frontendandpackage-name/admin.- To use
Groups, you will have to define at least 1Area
Creation
This will make a Asset instance based on the given params. See the Asset documentation for posibilities.
$asset = Asset::create('script', 'global/plugins/jquery.min.js');
Compilation
This will run all configured filters on the asset and write the result to the cache_path. Returns an instance of Compiler\Compiled
$compiled = Asset::compile('script', 'global/plugins/jquery.min.js'); echo $compiled->getUrl(); # full url to the compiled asset echo $compiled->getHtml(); # script/link html tag echo $compiled->getUri(); # uri to the compiled asset echo $compiled->getPath(); # absolute file path to the compiled asset
Grouping
Grouping assets brings a few advantages:
- Allows dependency definitions for
Assets within itsGroup - Allows dependency definitions for
Groups within itsArea - Manually or automaticly compile and
Areas,Groups andAssets.
$area = Asset::area('area/package'); $group = $area->group('global'); $group->add('bootstrap', 'css/bootstrap.css'); $group->add('font-awesome', 'global/plugins/font-awesome/css/font-awesome.min.css', 'bootstrap');
Chaining
Asset::area('area/package') ->group('global') ->add('bootstrap', 'css/bootstrap.css') ->add('font-awesome', 'global/plugins/font-awesome/css/font-awesome.min.css', 'bootstrap'); // At a later point, you can continue adding Asset::area('area/package') ->group('global') ->add('simple-line-icons', 'global/plugins/simple-line-icons/simple-line-icons.min.css', 'bootstrap') ->add('uniform', 'global/plugins/uniform/css/uniform.default.css', 'bootstrap');
Compilation and output
After being done with defining the area/group, you can manually trigger compilation and use the Compiler\Compiled::getHtml method to output it.
Asset::area('area/package') ->group('global') ->compile('script', $combine = true) ->getHtml();
The Asset facade links to the Factory class instance. The area, group and asset definition utilize the NamespacedItemResolver.
This means some Factory methods accept such definitions:
// Query Asset::query // Compiles the scripts in group Asset::compile('script', 'area/package::global', $combine = true)->getHtml();