bryanjhv/laravel-blade-cdn
Composer 安装命令:
composer require bryanjhv/laravel-blade-cdn
包简介
Blade directive to get asset URLs according to environment.
README 文档
README
A Blade directive for getting asset URLs according to app environment.
Installation
Require this package with Composer using the following command
composer require bryanjhv/laravel-blade-cdn
After updating Composer, add the service provider to the providers array in
your config/app.php file:
Bryanjhv\BladeCdn\BladeCdnServiceProvider::class,
Finally, publish the config file, so you can configure your own CDN aliases and prefix:
php artisan vendor:publish --provider="Bryanjhv\BladeCdn\BladeCdnServiceProvider" --tag=config
Usage
Important: First at all, please remove all your cached views, using:
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):
<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:
<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:
<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.
License
This project is released under the MIT license.
统计信息
- 总下载量: 178
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-08-14