Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/bryanjhv/laravel-blade-cdn

A Blade directive for getting asset URLs according to app environment.
https://github.com/bryanjhv/laravel-blade-cdn

Last synced: about 2 months ago
JSON representation

A Blade directive for getting asset URLs according to app environment.

Awesome Lists containing this project

README

        

# Laravel Blade CDN

A [Blade][blade] directive for getting asset URLs according to app environment.

## Installation

Require this package with [Composer][composer] using the following command

```bash
composer require bryanjhv/laravel-blade-cdn
```

After updating Composer, add the service provider to the `providers` array in
your `config/app.php` file:

```php
Bryanjhv\BladeCdn\BladeCdnServiceProvider::class,
```

Finally, publish the config file, so you can configure your own CDN aliases and
prefix:

```bash
php artisan vendor:publish --provider="Bryanjhv\BladeCdn\BladeCdnServiceProvider" --tag=config
```

## Usage

**Important**: First at all, please remove all your cached views, using:

```bash
php artisan view:clear
```

The service provider makes the `@cdn` Blade directive available, so you can use
it like so (working on `resources/views/sample.blade.php`):

```blade

```

The above code will be expanded, in production, using the default configuration
file the package ships with, to:

```php

```

Or, in any other environment, to:

```php

```

Of course, you may define any custom alias and prefix after publishing the
configuration by editing the `config/blade-cdn.php` file.

## License

This project is released under the MIT license.

[blade]: https://laravel.com/docs/blade
[composer]: https://getcomposer.org