nhatphamcdn / assets-manage
Laravel manage assets
dev-master
2019-09-03 03:02 UTC
Requires (Dev)
- orchestra/testbench: ^3.8
This package is auto-updated.
Last update: 2025-06-29 01:34:41 UTC
README
#Simple Asset Manager for Laravel
Installation
- Run
composer require nhatphamcdn/assets-manage
- Add
Nhatphamcdn\AssetsManage\AssetsManageServiceProvider::class
to app configproviders
array - Run
php artisan vendor:publish --provider="Nhatphamcdn\AssetsManage\AssetsManageServiceProvider" --tag="config"
Configuration
All the assets are defined as key-value pairs in the assets
array. The key would then be used in the view files to include the resources, e.g. @css('animate')
.
Example usage
config/assets.php
'assets' => [
'animate' => [
'css' => 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css'
],
'tagsinput' => [
'css' => 'https://cdnjs.cloudflare.com/ajax/libs/bootstrap-tagsinput/0.8.0/bootstrap-tagsinput.css',
'js' => 'https://cdnjs.cloudflare.com/ajax/libs/bootstrap-tagsinput/0.8.0/bootstrap-tagsinput.min.js'
],
'datatables' => [
'css' => 'https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.12/css/dataTables.bootstrap.min.css',
'js' => [
'https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.12/js/jquery.dataTables.min.js',
'https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.12/js/dataTables.bootstrap.min.js'
]
],
...
]
view.blade.php
@css('animate', 'tagsinput', 'datatables')
@js('tagsinput', 'datatables')
This will create asset inclusions in your html with the corresponding urls.
You can also call urls directly
@css('http://link-stylesheet.css')
@js('https://link-js.js')