arrounded / assets
The description of the module
Installs: 1 645
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 0
pkg:composer/arrounded/assets
Requires
- php: >=5.5.9
- illuminate/console: ^5.2
- illuminate/support: ^5.2
- symfony/finder: ^3.0
Requires (Dev)
- fabpot/php-cs-fixer: 2.0.*@dev
- mockery/mockery: ^0.9.4
- phpspec/phpspec: ^2.2
- phpunit/phpunit: ^4.7
- symfony/var-dumper: ^2.7
This package is auto-updated.
Last update: 2019-11-15 14:46:32 UTC
README
Install
Via Composer
$ composer require arrounded/assets
Usage
Assets pipeline
To use the assets pipeline create a config/assets.php file. In it you can define various collection of assets:
<?php return [ 'global' => [ 'css' => [ 'foo.css', ], ], 'admin' => [ 'css' => ['admin.css'], 'js' => ['admin.js'], ], ];
Add its service provider in config/app.php
Arrounded\Assets\ServiceProvider::class,
Then add the facade in the same file:
'Assets' => Arrounded\Assets\Facades\Assets::class,
Now in your views you can call this class to output a collection of assets:
{{ Assets.styles('global') }}
{{ Assets.scripts('admin') }}
AssetsReplacer
When going to production, you don't want to leave the Assets.styles and Assets.scripts calls as is as they will return the assets individually.
The AssetsReplacer class will replace these calls with their actual values so usemin can read them and consume them.
$replacer = new AssetsReplacer($assetsHandler); $replacer->replaceInFolder('resources/views');
JavascriptBridge
This is a class to pass data to the front-end. You can pass it as globals or namespaced. It's a static class so you can call it anywhere:
JavascriptBridge::add(['foo' => 'bar']); JavascriptBridge::render(); // var foo = "bar"; JavascriptBridge::setNamespace('Arrounded'); JavascriptBridge::add(['foo' => 'bar']); JavascriptBridge::render(); // var Arrounded = {}; Arrounded.foo = "bar";
It can also render classes implementing the Jsonable interface.
Testing
$ composer test
License
The MIT License (MIT). Please see License File for more information.