https://github.com/genentech/laravel-cdn-middleware
A Basic integration for pull zone CDN's for laravel.
https://github.com/genentech/laravel-cdn-middleware
Last synced: about 1 year ago
JSON representation
A Basic integration for pull zone CDN's for laravel.
- Host: GitHub
- URL: https://github.com/genentech/laravel-cdn-middleware
- Owner: Genentech
- License: mit
- Created: 2015-03-26T20:17:32.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2016-08-02T22:22:05.000Z (almost 10 years ago)
- Last Synced: 2025-03-29T10:34:13.714Z (about 1 year ago)
- Language: PHP
- Homepage:
- Size: 25.4 KB
- Stars: 0
- Watchers: 23
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Laravel 5 CDN Middleware
A Basic middleware integration for pull zone CDN's for laravel
# Composer Installation
Add/integrate the following to your project's composer.json file.
```javascript
"repositories": [
{
"type": "git",
"url": "git@github.com:Genentech/laravel5-cdn-views.git"
}
],
"require": {
"Genentech/laravel5-cdn-views": "dev-master"
}
```
# Configuration
After it's installed run
```bash
php artisan vendor:publish
```
And then configure the file at /config/laravel5-cdn-views.php
# Usage
add the following to your providers list
```php
Genentech\CdnViews\CdnViewServiceProvider
```
and add the following to app/Http/Kernel.php
```php
Genentech\CdnViews\Middleware\UseCDN
```
root relative urls will be transformed, and //:resource urls will not
not root relative urls will be left intact and logged
You can also invoke the CDN helper yourself and convert urls using
```php
$pullzone = 'https://cdn.com'; // or Config::get('laravel5-cdn-views.cdn_url');
$validTags = ['style', 'scripts']; // or Config::get('laravel5-cdn-views.tags');
$cdn_helper = new CdnHelper(CDN_URL, $this->validTags);
$cdn_url = $cdn_helper->convertUrl('/foo.txt');
```