For example, the generated file name will look something like:
`all-16d570a7.css`.
In Laravel, you can use in your views the `elixir()` function to load
the appropriately hashed asset:
``` html
<link rel="stylesheet" href="{{ elixir("css/all.css") }}">
This twig extension is an adaptation of this elixir() function., (*4)
Requirements
You need PHP >= 5.5.9 to use the library, but the latest stable version
of PHP is recommended., (*5)
This will edit (or create) your composer.json file and automatically
choose the most recent version.
## Documentation
### Register the extension
``` php
use BrieucThomas\Twig\Extension\ElixirExtension;
$elixir = new ElixirExtension(
$publicDir, // the absolute public directory
$buildDir, // the elixir build directory (default value is 'build')
$manifestName // the manifest filename (default value is 'rev-manifest.json')
);
$twig->addExtension($elixir);
### Create a gulpfile
Here an example of `gulpfile.js` to compile and version
the script `app/Resources/js/app.js` :
```javascript
// gulpfile.js
const elixir = require('laravel-elixir');
elixir.config.assetsPath = 'app/Resources';
elixir.config.publicPath = 'web';
elixir.config.appPath = 'src';
elixir.config.viewPath = 'app/Resources/views';
elixir(function(mix) {
// compile scripts to web/js/all.js (default output)
mix.scripts(['app.js']);
// version compiled scripts
mix.version(['js/all.js']);
});
Using the Extension
``` twig
, (*10)
You can surround with the `asset` twig extension to make your
application more portable:
``` twig
<link rel="stylesheet" href="{{ asset(elixir('css/all.css')) }}">
<script src="{{ asset(elixir('js/all.js')) }}"></script>