administrcms/asset-manager
Assets manager
Installation
Using Composer:
composer require administrcms/asset-manager
Add the service provider:
\Administr\Assets\AssetsServiceProvider::class,
The Facade:
'Asset' => \Administr\Assets\AssetsFacade::class,
Usage
Base usage
The asset manager works with the Laravel framework. It provides a Facade for easier usage.
You can specify your asset groups by either the add method or using the magical method.
Asset::add('test.css', 'css');
// is the same as
Asset::addCss('test.css');
You can retrieve a group either by the get method or the magical equivelent.
Asset::get('css');
// is the same as
Asset::getCss();
You can also specify a priority for your asset. For example when using the jQuery library, you need to include it before any other library that depends on it.
// The sort is from highest to lowest priority. The default priority is 0.
Asset::addJs('jquery.js', 100);
Asset::add('jquery.js', 'js', 100);
Shortcuts
You can define a shortcut, which is a class that defines multiple assets at once. If you are using a js library that needs to include js and css code, you can make it easier.
// Create a class that implements the Shortcut contract
class WysiwygShortcut implements Administr\Assets\Contracts\Shortcut {
public function execute()
{
Asset::addJs('tinymce.js');
Asset::addCss('tinymce.css');
Asset::addCss('tinymce.theme.css');
}
}
// Register it with the Asset Manager
Asset::shortcut('wysiwyg', WysiwygShortcut::class);
// And then call it like a method of the Manager
Asset::wysiwyg();
It is up to you to decide where to register the shortcuts. A good place would be in a ServiceProvider in you Laravel app.
Related Packages
Powerful PHP database abstraction layer (DBAL) with many features for database s...
Laravel Serializable Closure provides an easy and secure way to serialize closur...
Cli error handling for console/command-line PHP applications.
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| 1.1.4 | >=5.5.9 | >=5.2 | MIT | |
| 1.1.3 | >=5.5.9 | >=5.2 | MIT | |
| 1.1.2 | >=5.5.9 | >=5.2 | MIT | |
| 1.1.1 | >=5.5.9 | 5.2.* | MIT | |
| 1.1.0 | >=5.5.9 | 5.2.* | MIT | |
| 1.0.1 | >=5.5.9 | 5.2.* | MIT | |
| 1.0.0 | >=5.5.9 | 5.2.* | MIT |