2017 © Pedro Peláez
 

library laravel-blade-cdn

Blade directive to get asset URLs according to environment.

image

bryanjhv/laravel-blade-cdn

Blade directive to get asset URLs according to environment.

  • Sunday, November 20, 2016
  • by bryanjhv
  • Repository
  • 1 Watchers
  • 1 Stars
  • 164 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 4 Versions
  • 1 % Grown

The README.md

Laravel Blade CDN

A Blade directive for getting asset URLs according to app environment., (*1)

Installation

Require this package with Composer using the following command, (*2)

composer require bryanjhv/laravel-blade-cdn

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

Bryanjhv\BladeCdn\BladeCdnServiceProvider::class,

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

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

Usage

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

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):, (*6)

<link rel="stylesheet" href="@cdn('bootstrap-css')" />
<script src="@cdn('jquery')"></script>
<script src="@cdn('bootstrap-js')"></script>
<script src="@cdn('js/main.js')"></script>

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

<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" />
<script src="//code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="<?php echo asset('js/main.js'); ?>"></script>

Or, in any other environment, to:, (*8)

<link rel="stylesheet" href="<?php echo asset('css/bootstrap.min.css'); ?>" />
<script src="<?php echo asset('js/jquery.min.js'); ?>"></script>
<script src="<?php echo asset('js/bootstrap.min.js'); ?>"></script>
<script src="<?php echo asset('js/main.js'); ?>"></script>

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

License

This project is released under the MIT license., (*10)

The Versions

20/11 2016

dev-master

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

Blade directive to get asset URLs according to environment.

  Sources   Download

MIT

The Requires

 

laravel url cdn asset blade directive

13/09 2016

1.0.2

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

Blade directive to get asset URLs according to environment.

  Sources   Download

MIT

The Requires

 

laravel url cdn asset blade directive

15/08 2016

1.0.1

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

Blade directive to get asset URLs according to environment.

  Sources   Download

MIT

The Requires

 

laravel url cdn asset blade directive

14/08 2016

1.0.0

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

Blade directive to get asset URLs according to environment.

  Sources   Download

MIT

The Requires

 

laravel url cdn asset blade directive