Download the PHP package modbase/asset-manager without Composer
On this page you can find all versions of the php package modbase/asset-manager. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download modbase/asset-manager
More information about modbase/asset-manager
Files in modbase/asset-manager
Package asset-manager
Short Description A very basic asset manager to be used in combination with versioned assets.
License MIT
Informations about the package asset-manager
Note: this project has been discontinued in favor of Elixir
Asset Manager
This is a little helper package for Laravel to use in combination with e.g. Gulp.
The advantage of this package is that it automatically handles versioned assets. With versioned assets, you can benefit from cache busting when an asset changes. This way your clients will always use the correct assets and not an old cached version.
For example the gulpfile.js
below will produce a public/css/styles-{hash}.css
and public/js/scripts-{hash}.js
file where {hash}
is the MD5 hash of the built file.
By using the Asset
facade, you'll be able to include these assets without having to take care of those hashes.
For example Asset::scripts('frontend')
would result in <script scr="public/js/scripts-627d37eb.js"></script>
.
Installation
- Add
"modbase/asset-manager": "0.1.*"
to yourcomposer.json
file. - Run
composer update
- Add
'Modbase\AssetManager\AssetManagerServiceProvider'
to your service providers inapp/config/app.php
.
Example gulpfile.js
Laravel Facade
Use this in your views: Asset::styles('frontend')
and Asset::scripts('frontend')
.
The arguments of the styles()
and scripts()
methods correspond to the bundleName
prefix you've given in the gulpfile.js. In the example above, it was frontend
. Always end the bundleName with .scripts
or .styles
so that the AssetManager knows what to fetch.
Example workflow
- Use the above example gulpfile.js and update whatever you want, but be careful with the bundleName option!
- In your master.blade.php (assuming you're using the awesome Blade template engine and have a master layout) add
{{ Asset::styles('frontend') }}
to your head section. Add{{ Asset::scripts('frontend') }}
at the bottom of your HTML (you should put your JavaScript at the bottom, just before the closing body tag to speed up loading). - Add your assets to
app/assets/css
andapp/assets/js
(according to the gulpfile.js paths). - Run
gulp
orgulp css
orgulp js
everytime you update your assets (or simply use a gulp watch). - Enjoy!