PHPackages                             breachaware/laravel-cdn - 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. breachaware/laravel-cdn

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

breachaware/laravel-cdn
=======================

Content Delivery Network (CDN) Package for Laravel

v0.0.1(6y ago)095MITPHPPHP ^7.1.3

Since May 30Pushed 6y ago1 watchersCompare

[ Source](https://github.com/breachaware/laravel-cdn)[ Packagist](https://packagist.org/packages/breachaware/laravel-cdn)[ RSS](/packages/breachaware-laravel-cdn/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (7)Versions (2)Used By (0)

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

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

THIS PACKAGE IS STILL IN DEVELOPMENT. DO NOT USE THIS PACKAGE IN PRODUCTION!

##### A Content Delivery Network package for Laravel

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

The package allows you to upload your static assets to AWS S3 with a single Artisan command. Optionally, you may configure a CloudFront or CloudFlare URL.

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) and [publiux/laravelcdn](https://github.com/publiux/laravelcdn)

[](#fork-from-vinelabcdn-and-publiuxlaravelcdn)

This project has been forked from , which was forked from . All credit for the original work goes to Vinelab and publiux.

#### Laravel Support

[](#laravel-support)

- This package supports Laravel 5.5 up to an including Laravel 5.8 (`master`).
- This package supports Laravel's package auto-discovery.

Highlights
----------

[](#highlights)

- Support for AWS S3
- Support for AWS CloudFront
- Support for CloudFlare with an AWS S3 origin
- Artisan command to upload content to AWS S3
- A simple facade to access CDN assets including support for versioned assets using Laravel Mix.

### 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 `breachaware/laravel-cdn` in your project:

```
composer require breachaware/laravel-cdn
```

```
'providers' => array(
    //...
    BreachAware\LaravelCdn\CdnServiceProvider::class,
),
```

```
'aliases' => [
    //...
    'CDN' => BreachAware\LaravelCdn\Facades\CdnFacade::class,
],
```

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

Publish the package config file:

```
php artisan vendor:publish --provider "BreachAware\LaravelCdn\CdnServiceProvider"
```

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

[](#environment-configuration)

This package can be configured by editing the config/cdn.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.

#### Retrieving Asset URLs

[](#retrieving-asset-urls)

There are two primary options when retrieving the CDN URL of a static asset:

##### Unversioned assets

[](#unversioned-assets)

Use the `CDN` facade 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('css/app.css') }}     // example result: https://cdn.yourdomain.com/css/app.css
{{ CDN::asset('js/app.js') }}       // example result: https://cdn.yourdomain.com/js/app.js
```

##### Versioned assets using Laravel Mix

[](#versioned-assets-using-laravel-mix)

Use the `CDN` facade to call the `CDN::mix()` method.

*Note: the `mix` method works by parsing the `mix-manifest.json` file that is generated by webpack, the same as `Laravel Mix`.*

```
{{ CDN::mix('css/app.css') }}     // example result: https://cdn.yourdomain.com/css/app.css?id=2f7c00b6f09552c3f0ce
{{ CDN::mix('js/app.js') }}       // example result: https://cdn.yourdomain.com/js/app.js?id=dbd07402af699be7a212
```

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/breachaware/laravel-cdn/issues)

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

[](#contributing)

Please see [CONTRIBUTING](https://github.com/breachaware/laravel-cdn/blob/master/CONTRIBUTING.md) for details.

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

[](#security-related-issues)

If you discover any security related issues, please do not raise a Github issue. Instead, please email  with the details of the vulnerability.

Credits
-------

[](#credits)

- [Mahmoud Zalt](https://github.com/Mahmoudz) (original developer)
- [Raul Ruiz](https://github.com/publiux) (pre-fork contributor)
- [Filipe Garcia](https://github.com/filipegar) (pre-fork contributor)
- [Contributors from original project](https://github.com/Vinelab/cdn/graphs/contributors)
- [Brent Kozjak](https://github.com/brentkozjak) (current maintainer)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](https://github.com/breachaware/laravel-cdn/blob/master/LICENSE) for more information.

Changelog
---------

[](#changelog)

#### v1.0.0

[](#v100)

- Initial release from BreachAware

*Note: The version history has been reset since forking from the original package.*

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

2539d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0c046a0ea342c78059adc806395d1cacd3cb892c904f1daac369e6438dd5134b?d=identicon)[brentkozjak](/maintainers/brentkozjak)

---

Top Contributors

[![brentkozjak](https://avatars.githubusercontent.com/u/70180107?v=4)](https://github.com/brentkozjak "brentkozjak (2 commits)")

---

Tags

laravelamazons3awsuploadcdnaws-s3content delivery networkAssets Upload

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/breachaware-laravel-cdn/health.svg)

```
[![Health](https://phpackages.com/badges/breachaware-laravel-cdn/health.svg)](https://phpackages.com/packages/breachaware-laravel-cdn)
```

###  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)
