Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/botble/laravel-assets
Assets management for Laravel application
https://github.com/botble/laravel-assets
assets-management botble botblecms laravel laravel-5-package
Last synced: 1 day ago
JSON representation
Assets management for Laravel application
- Host: GitHub
- URL: https://github.com/botble/laravel-assets
- Owner: botble
- License: mit
- Created: 2018-10-23T02:36:23.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-07-19T04:06:11.000Z (6 months ago)
- Last Synced: 2025-01-08T14:23:33.025Z (8 days ago)
- Topics: assets-management, botble, botblecms, laravel, laravel-5-package
- Language: PHP
- Homepage: https://botble.com
- Size: 74.2 KB
- Stars: 46
- Watchers: 4
- Forks: 23
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Laravel Assets management
[![Latest Version](https://img.shields.io/github/release/botble/laravel-assets.svg?style=flat-square)](https://github.com/botble/laravel-assets/releases)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)
[![Quality Score](https://img.shields.io/scrutinizer/g/botble/laravel-assets.svg?style=flat-square)](https://scrutinizer-ci.com/g/botble/laravel-assets)
[![StyleCI](https://styleci.io/repos/154250020/shield)](https://styleci.io/repos/154250020)
[![Total Downloads](https://img.shields.io/packagist/dt/botble/assets.svg?style=flat-square)](https://packagist.org/packages/botble/assets)
[![Maintainability](https://api.codeclimate.com/v1/badges/a6e4612307e3b3bf8252/maintainability)](https://codeclimate.com/github/botble/laravel-assets/maintainability)## Installation
```bash
composer require botble/assets
```For version <= 5.4:
Add to section `providers` of `config/app.php`:
```php
// config/app.php
'providers' => [
...
Botble\Assets\Providers\AssetsServiceProvider::class,
];
```And add to `aliases` section:
```php
// config/app.php
'aliases' => [
...
'Assets' => Botble\Assets\Facades\AssetsFacade::class,
];
```All assets resource will be manage in config file so we need to publish config to use.
```bash
php artisan vendor:publish --provider="Botble\Assets\Providers\AssetsServiceProvider" --tag=config
```Add to your master layout view, in `head` tag:
```php
{!! \Assets::renderHeader() !!}
```and before `body` tag close:
```php
{!! \Assets::renderFooter() !!}
```## Methods
### Add scripts
```php
\Assets::addScripts(['key-of-assets-in-config-file']);
```Example:
```php
\Assets::addScripts(['app', 'bootstrap', 'jquery']);
```### Add styles
```php
\Assets::addStyles(['key-of-assets-in-config-file']);
```Example:
```php
\Assets::addStyles(['bootstrap', 'font-awesome']);
```### Remove scripts
```php
\Assets::removeScripts(['key-of-assets-in-config-file']);
```Example:
```php
\Assets::removeScripts(['bootstrap']);
```### Remove styles
```php
\Assets::removeStyles(['key-of-assets-in-config-file']);
```Example:
```php
\Assets::removeStyles(['font-awesome']);
```### Others
- Set version for assets. Add to `.env`
```bash
ASSETS_VERSION=1.0
```Then all assets will be added `?v=1.0`
- Change to online mode
```bash
ASSETS_OFFLINE=false
```Then assets will be loaded from CDN if it's defined in config file.
- To disable versioning:
```bash
ASSETS_ENABLE_VERSION=false
```## Contributors
- [Sang Nguyen](https://github.com/sangnguyenplus)
- [Dinh Quoc Han](https://github.com/dinhquochan)## License
[MIT](LICENSE) © Sang Nguyen