PHPackages                             abhinavdobhal/laravelcdn - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. abhinavdobhal/laravelcdn

ActiveLibrary[File &amp; Storage](/categories/file-storage)

abhinavdobhal/laravelcdn
========================

Content Delivery Network (CDN) Package for Laravel

v2.0.8(7y ago)32.1kMITPHPPHP &gt;=5.5.9

Since Jan 17Pushed 1y agoCompare

[ Source](https://github.com/AbhinavDobhal/laravelcdn)[ Packagist](https://packagist.org/packages/abhinavdobhal/laravelcdn)[ RSS](/packages/abhinavdobhal-laravelcdn/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (7)Versions (15)Used By (0)

Laravel CDN Assets Manager
==========================

[](#laravel-cdn-assets-manager)

[![Latest Stable Version](https://camo.githubusercontent.com/a3b6e04f6458ba29b34a13c2418ca115016713745930d15d46e1c53ed6cd2c44/68747470733a2f2f706f7365722e707567782e6f72672f7075626c6975782f6c61726176656c63646e2f762f737461626c65)](https://packagist.org/packages/abhinavdobhal/laravelcdn)[![Total Downloads](https://camo.githubusercontent.com/94ebc08bed7e9154cbbab8f140ed368c29c9ca22a1c5d54d70c9362bd1ca0624/68747470733a2f2f706f7365722e707567782e6f72672f616268696e6176646f6268616c2f6c61726176656c63646e2f646f776e6c6f616473)](https://packagist.org/packages/abhinavdobhal/laravelcdn)[![License](https://camo.githubusercontent.com/b9eaef834269f4827fbddbb961496d84e231143e9e46bdc7a94bd9b173eb382d/68747470733a2f2f706f7365722e707567782e6f72672f616268696e6176646f6268616c2f6c61726176656c63646e2f6c6963656e7365)](https://packagist.org/packages/abhinavdobhal/laravelcdn)

##### Content Delivery Network Package for Laravel

[](#content-delivery-network-package-for-laravel)

The package provides the developer the ability to upload their assets (or any public file) to a CDN with a single artisan command. And then it allows them to switch between the local and the online version of the files.

###### Fork From [Vinelab/cdn](https://github.com/Vinelab/cdn)

[](#fork-from-vinelabcdn)

This project has been forked from . All credit for the original work goes there.

#### Laravel Support

[](#laravel-support)

- This fork supports Laravel 5.2 up to an including Laravel 5.5 (`master`).
- Laravel 5.5 is supported, as is package auto-discovery.

Highlights
----------

[](#highlights)

- Amazon Web Services (AWS) - S3
- DigitalOcean (DO) - Spaces
- Artisan command to upload content to CDN
- Simple Facade to access CDN assets

### Questions

[](#questions)

1. Is this package an alternative to Laravel FileSystem and do they work together?

- No, the package was introduced in Laravel 4 and it's main purpose is to manage your CDN assets by loading them from the CDN into your Views pages, and easily switch between your Local and CDN version of the files. As well it allows you to upload all your assets with single command after specifying the assets directory and rules. The FileSystem was introduced in Laravel 5 and it's designed to facilitate the loading/uploading of files form/to a CDN. It can be used the same way as this Package for loading assets from the CDN, but it's harder to upload your assets to the CDN since it expect you to upload your files one by one. As a result this package still not a replacement of the Laravel FileSystem and they can be used together.

Installation
------------

[](#installation)

#### Via Composer

[](#via-composer)

Require `publiux/laravelcdn` in your project:

```
composer require "publiux/laravelcdn:~2.0"
```

*If you are using Laravel 5.4 or below, you need to register the service provider:*

Laravel 5.4 and below: Add the service provider and facade to `config/app.php`:

```
'providers' => array(
     //...
     Publiux\laravelcdn\CdnServiceProvider::class,
),
```

```
'aliases' => array(
     //...
     'CDN' => Publiux\laravelcdn\Facades\CdnFacadeAccessor::class
),
```

*If you are using Laravel 5.5, there is no need to register the service provider as this package is automatically discovered.*

Publish the package config file:

```
php artisan vendor:publish --provider 'Publiux\laravelcdn\CdnServiceProvider'
```

Environment Configuration
-------------------------

[](#environment-configuration)

This package can be configured by editing the config/app.php file. Alternatively, you can set many of these options in as environment variables in your '.env' file.

##### AWS Credentials

[](#aws-credentials)

Set your AWS Credentials and other settings in the `.env` file.

*Note: you should always have an `.env` file at the project root, to hold your sensitive information. This file should usually not be committed to your VCS.*

```
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
```

##### CDN URL

[](#cdn-url)

Set the CDN URL:

```
'url' => env('CDN_Url', 'https://s3.amazonaws.com'),
```

This can altered in your '.env' file as follows:

```
CDN_Url=
```

##### Bypass

[](#bypass)

To load your LOCAL assets for testing or during development, set the `bypass` option to `true`:

```
'bypass' => env('CDN_Bypass', false),
```

This can be altered in your '.env' file as follows:

```
CDN_Bypass=
```

##### Cloudfront Support

[](#cloudfront-support)

```
'cloudfront'    => [
    'use' => env('CDN_UseCloudFront', false),
    'cdn_url' => env('CDN_CloudFrontUrl', false)
],
```

This can be altered in your '.env' file as follows:

```
CDN_UseCloudFront=
CDN_CloudFrontUrl=
```

##### Default CDN Provider

[](#default-cdn-provider)

For now, the only CDN provider available is AwsS3. Although, as DO natively support the AWS API, you can utilise it by also providing the endpoint, please see the cdn.php config for more info. This option cannot be set in '.env'.

```
'default' => 'AwsS3',
```

##### CDN Provider Configuration

[](#cdn-provider-configuration)

```
'aws' => [

    's3' => [

        'version'   => 'latest',
        'region'    => '',
        'endpoint'  => '', // For DO Spaces

        'buckets' => [
            'my-backup-bucket' => '*',
        ]
    ]
],
```

###### Multiple Buckets

[](#multiple-buckets)

```
'buckets' => [

    'my-default-bucket' => '*',

    // 'js-bucket' => ['public/js'],
    // 'css-bucket' => ['public/css'],
    // ...
]
```

#### Files &amp; Directories

[](#files--directories)

###### Include:

[](#include)

Specify directories, extensions, files and patterns to be uploaded.

```
'include'    => [
    'directories'   => ['public/dist'],
    'extensions'    => ['.js', '.css', '.yxz'],
    'patterns'      => ['**/*.coffee'],
],
```

###### Exclude:

[](#exclude)

Specify what to be ignored.

```
'exclude'    => [
    'directories'   => ['public/uploads'],
    'files'         => [''],
    'extensions'    => ['.TODO', '.txt'],
    'patterns'      => ['src/*', '.idea/*'],
    'hidden'        => true, // ignore hidden files
],
```

##### Other Configurations

[](#other-configurations)

```
'acl'           => 'public-read',
'metadata'      => [ ],
'expires'       => gmdate("D, d M Y H:i:s T", strtotime("+5 years")),
'cache-control' => 'max-age=2628000',
```

You can always refer to the AWS S3 Documentation for more details: [aws-sdk-php](http://docs.aws.amazon.com/aws-sdk-php/v3/guide/)

Usage
-----

[](#usage)

You can 'push' your assets to your CDN and you can 'empty' your assets as well using the commands below.

#### Push

[](#push)

Only changed assets are pushed to the CDN. (THanks, )

Upload assets to CDN

```
php artisan cdn:push
```

You can specify a folder upload prefix in the cdn.php config file. Your assets will be uploaded into that folder on S3.

#### Empty

[](#empty)

Delete assets from CDN

```
php artisan cdn:empty
```

CAUTION: This will erase your entire bucket. This may not be what you want if you are specifying an upload folder when you push your assets.

#### Load Assets

[](#load-assets)

Use the facade `CDN` to call the `CDN::asset()` function.

*Note: the `asset` works the same as the Laravel `asset` it start looking for assets in the `public/` directory:*

```
{{CDN::asset('assets/js/main.js')}}        // example result: https://js-bucket.s3.amazonaws.com/public/assets/js/main.js

{{CDN::asset('assets/css/style.css')}}        // example result: https://css-bucket.s3.amazonaws.com/public/assets/css/style.css
```

*Note: the `elixir` works the same as the Laravel `elixir` it loads the manifest.json file from build folder and choose the correct file revision generated by gulp:*

```
{{CDN::elixir('assets/js/main.js')}}        // example result: https://js-bucket.s3.amazonaws.com/public/build/assets/js/main-85cafe36ff.js

{{CDN::elixir('assets/css/style.css')}}        // example result: https://css-bucket.s3.amazonaws.com/public/build/assets/css/style-2d558139f2.css
```

*Note: the `mix` works the same as the Laravel 5.4 `mix` it loads the mix-manifest.json file from public folder and choose the correct file revision generated by webpack:*

```
{{CDN::mix('/js/main.js')}}        // example result: https://js-bucket.s3.amazonaws.com/public/js/main-85cafe36ff.js

{{CDN::mix('/css/style.css')}}        // example result: https://css-bucket.s3.amazonaws.com/public/css/style-2d558139f2.css
```

To use a file from outside the `public/` directory, anywhere in `app/` use the `CDN::path()` function:

```
{{CDN::path('private/something/file.txt')}}        // example result: https://css-bucket.s3.amazonaws.com/private/something/file.txt
```

Test
----

[](#test)

To run the tests, run the following command from the project folder.

```
$ ./vendor/bin/phpunit
```

Support
-------

[](#support)

Please request support or submit issues [via Github](https://github.com/publiux/laravelcdn/issues)

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/publiux/laravelcdn/blob/master/CONTRIBUTING.md) for details.

Security Related Issues
-----------------------

[](#security-related-issues)

If you discover any security related issues, please email  instead of using the issue tracker for faster response. You should open an issue at the same time.

Credits
-------

[](#credits)

- [Raul Ruiz](https://github.com/publiux) (forker)
- [Mahmoud Zalt](https://github.com/Mahmoudz) (original developer)
- [Filipe Garcia](https://github.com/filipegar) (contributred pre-fork, uncredited pull request for duplicate uploading verification)
- [Contributors from original project](https://github.com/Vinelab/cdn/graphs/contributors)
- [All Contributors for this Fork](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](https://github.com/publiux/laravelcdn/blob/master/LICENSE) for more information.

Changelog
---------

[](#changelog)

#### v2.0.5

[](#v205)

- Added connection error reporting

#### v2.0.4

[](#v204)

- Added API support for DigitalOcean Spaces

#### v2.0.3

[](#v203)

- Added support for an upload folder prefix

#### v2.0.2

[](#v202)

- Updated readme to detail instructions on Laravel &lt;5.5 usage

#### v2.0.1

[](#v201)

- Fixed typo in composer.json

#### v2.0.0

[](#v200)

- Support for Laravel 5.5

#### v1.0.3

[](#v103)

- Fixed bug where schemeless Urls could not be used for CloudFront. Valid urls now begin with http, https, or simply '//'

#### v1.0.2

[](#v102)

- Fixed bug where the elixir function was inadvertently omitted from the release.

#### v1.0.1

[](#v101)

- Allow configuration using environment values

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance28

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 71.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~80 days

Recently: every ~54 days

Total

13

Last Release

2802d ago

Major Versions

v1.0.3 → 2.0.02017-09-05

### Community

Maintainers

![](https://www.gravatar.com/avatar/2fc4ebcbbafcc7d3b5049a84d96bbc1591b4bd72ca947c859d7ca9ccd67fdc07?d=identicon)[AbhinavDobhal](/maintainers/AbhinavDobhal)

---

Top Contributors

[![publiux](https://avatars.githubusercontent.com/u/2847188?v=4)](https://github.com/publiux "publiux (80 commits)")[![AbhinavDobhal](https://avatars.githubusercontent.com/u/35193029?v=4)](https://github.com/AbhinavDobhal "AbhinavDobhal (18 commits)")[![nyxsoftwaresystems](https://avatars.githubusercontent.com/u/71080572?v=4)](https://github.com/nyxsoftwaresystems "nyxsoftwaresystems (11 commits)")[![markokeeffe](https://avatars.githubusercontent.com/u/1211393?v=4)](https://github.com/markokeeffe "markokeeffe (1 commits)")[![mul14](https://avatars.githubusercontent.com/u/113989?v=4)](https://github.com/mul14 "mul14 (1 commits)")[![samdoidge](https://avatars.githubusercontent.com/u/845238?v=4)](https://github.com/samdoidge "samdoidge (1 commits)")

---

Tags

laravelamazons3awsuploadcdnaws-s3content delivery networkAssets Upload

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/abhinavdobhal-laravelcdn/health.svg)

```
[![Health](https://phpackages.com/badges/abhinavdobhal-laravelcdn/health.svg)](https://phpackages.com/packages/abhinavdobhal-laravelcdn)
```

###  Alternatives

[vinelab/cdn

Content Delivery Network (CDN) Package for Laravel

217240.8k1](/packages/vinelab-cdn)[publiux/laravelcdn

Content Delivery Network (CDN) Package for Laravel

155230.4k](/packages/publiux-laravelcdn)[aws/aws-sdk-php-laravel

A simple Laravel 9/10/11/12/13 service provider for including the AWS SDK for PHP.

1.7k35.6M75](/packages/aws-aws-sdk-php-laravel)[juhasev/laravelcdn

Content Delivery Network (CDN) Package for Laravel

1820.4k](/packages/juhasev-laravelcdn)[unisharp/s3-presigned

An AWS S3 package for pre-signed upload purpose in Laravel and PHP.

151.8k](/packages/unisharp-s3-presigned)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
