The Asset Pipeline for Laravel 5.1, 5.2 & 5.3 !
The asset pipeline provides a framework to concatenate and minify or compress JavaScript and CSS assets. It also adds the ability to write these assets in other languages and pre-processors such as CoffeeScript, LESS, Sass and EJS.
For Laravel 4.1 or 4.2 supports see Larasset 0.9 branch
For Laravel 5.0 supports see Larasset 1.0 branch
For a more complete description of this package, you can read the Wiki docs:
Examples of Larasset usage.
php artisan larasset:precompile
: Precompile assets of your application, useful for your production environmentphp artisan larasset:serve
: Launch Larasset's server for serving assets, useful for your development environmentphp artisan server
: Serve your Laravel application on the PHP development server and also the Larasset's server for serving assetsYou can see this package in action with this online demo. And you can grab the source code of this demo here.
You must install Node.js on your computer (development environment only).
This package is only compatible with PHP >= 5.5 and Laravel >= 5.1 framework.
In the composer.json
, replace the line "minimum-stability": "stable"
by:
"minimum-stability": "dev"
Install Larasset package with composer:
composer require efficiently/larasset:1.2.*
Turn on your application debug mode, create or edit the config/app.php
file:
<?php
return [
'debug' => true,
// Others config options....
];
Note: It is strongly recommended that you turn off error detail in your production environment.
Add these services providers to config/app.php
:
'Collective\Html\HtmlServiceProvider',
'Efficiently\Larasset\LarassetServiceProvider',
'Efficiently\JqueryLaravel\JqueryLaravelServiceProvider',
Add these alias (facades) to your Laravel config/app.php
file:
'Form' => 'Collective\Html\FormFacade',
'HTML' => 'Collective\Html\HtmlFacade',
'Asset' => 'Efficiently\Larasset\Facades\Asset',
You can now add the this security Middleware to your app/Http/Kernel.php
file:
'Efficiently\JqueryLaravel\VerifyJavascriptResponse',
You will need install some Node.js modules in order to run these Larasset commands:
npm install -g larasset-js
Finally run php artisan larasset:setup
.
The rest of the installation depends on whether the asset pipeline is being used.
Run:
php artisan larasset:serve
NOTICE: You should use it only in a development/local environment
Run:
php artisan larasset:precompile
NOTICE: You are encouraged to use it in a production environment, for more informations, read the next section.
By default Larasset is running in development mode. That means that it will
recompile (server) any changed asset on demand. Also it's not compressing
JavaScript and/or Stylesheets in development mode. To run Larraset's server and
precompiler in production-ready mode, use --assets-env production
command line
option, like so:
php artisan larasset:precompile --assets-env production
larasset-js
1.2.0larasset-js
1.1.1humanize()
function helper to fix the image_tag()
helper (fix #15).larasset.port
config option.
For handling correctly the --larasset-port
option of the php artisan server
command.
Useful for your development environment when you run the assets server.
The default port value is 3000
.
You can change it in the config/larasset.php
file of your Laravel application.illuminate/html
package by the laravelcollective/html
package.config/app.php
file of your Laravel application:
'Illuminate\Html\HtmlServiceProvider',
by 'Collective\Html\HtmlServiceProvider',
'Form' => 'Illuminate\Html\FormFacade',
by 'Form' => 'Collective\Html\FormFacade',
'HTML' => 'Illuminate\Html\HtmlFacade',
by 'HTML' => 'Collective\Html\HtmlFacade',
humanize()
function helper to fix the image_tag()
helper (fix #15).humanize()
function helper to fix the image_tag()
helper (fix #15).--environment
command line option is renamed to --assets-env
. Because there was some conflicts with the Laravel command line option --env
. And larasset-environment
command line option is renamed to --larasset-env
.
See issue #6 for more information.Released under the MIT License.
It works well according to our tests. The internal API may change and other features will be added. We are working to make Larasset production quality software.