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

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

jetcod/laravel-cdn
==================

Content Delivery Network (CDN) Package for Laravel

v4.3.0(7mo ago)01.2k↓50%MITPHPPHP ^8.0CI passing

Since Jan 17Pushed 7mo agoCompare

[ Source](https://github.com/jetcod/laravel-cdn)[ Packagist](https://packagist.org/packages/jetcod/laravel-cdn)[ RSS](/packages/jetcod-laravel-cdn/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (10)Versions (26)Used By (0)

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

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

[![Build Status](https://github.com/jetcod/laravel-cdn/actions/workflows/php.yml/badge.svg?style=for-the-badge&label=%3Cb%3EBuild%3C/b%3E)](https://github.com/jetcod/laravel-cdn/actions)

[![Latest Stable Version](https://camo.githubusercontent.com/c8819feadfe3d1f769b83505ed48bc21d7624d89ebb2e1ec050a5a081fe705b2/687474703a2f2f706f7365722e707567782e6f72672f6a6574636f642f6c61726176656c2d63646e2f763f7374796c653d666f722d7468652d62616467652663616368654275737465723d31)](https://packagist.org/packages/jetcod/laravel-cdn)[![License](https://camo.githubusercontent.com/714945d92ef2720723384d10f45937ebac13875762d32994488791f0ec7e9b75/687474703a2f2f706f7365722e707567782e6f72672f6a6574636f642f6c61726176656c2d63646e2f6c6963656e73653f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/jetcod/laravel-cdn)

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

[](#fork-from-publiuxlaravelcdn)

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

#### Laravel Support

[](#laravel-support)

- This fork supports PHP 8.1+ and Laravel 8+.
- Package auto-discovery is supported.

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 `jetcod/laravelcdn` in your project:

```
composer require "jetcod/laravelcdn"
```

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

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

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.

```
$ composer test
```

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)

- [Hamid Ghorashi](https://github.com/hamidgh83) (forker)
- [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.

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance63

Regular maintenance activity

Popularity16

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity78

Established project with proven stability

 Bus Factor1

Top contributor holds 63% 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 ~177 days

Recently: every ~219 days

Total

21

Last Release

222d ago

Major Versions

v1.0.3 → 2.0.02017-09-05

v2.0.8 → v3.0.02020-05-18

v3.1.0 → v4.0.02022-12-10

PHP version history (3 changes)v1.0.0PHP &gt;=5.5.9

v4.0.0PHP &gt;=7.2.5

v4.2.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/4dedaadbfaf607c33c4b02a55eb9e3a4cf5407267d99d4b4eb7b3fe4a4f1e327?d=identicon)[hamidgh83](/maintainers/hamidgh83)

---

Top Contributors

[![publiux](https://avatars.githubusercontent.com/u/2847188?v=4)](https://github.com/publiux "publiux (92 commits)")[![hamidgh83](https://avatars.githubusercontent.com/u/3264788?v=4)](https://github.com/hamidgh83 "hamidgh83 (29 commits)")[![nyxsoftwaresystems](https://avatars.githubusercontent.com/u/71080572?v=4)](https://github.com/nyxsoftwaresystems "nyxsoftwaresystems (11 commits)")[![duxthefux](https://avatars.githubusercontent.com/u/6758162?v=4)](https://github.com/duxthefux "duxthefux (7 commits)")[![alexx876](https://avatars.githubusercontent.com/u/9285606?v=4)](https://github.com/alexx876 "alexx876 (3 commits)")[![samdoidge](https://avatars.githubusercontent.com/u/845238?v=4)](https://github.com/samdoidge "samdoidge (1 commits)")[![khoubeib-zembra](https://avatars.githubusercontent.com/u/67527415?v=4)](https://github.com/khoubeib-zembra "khoubeib-zembra (1 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)")

---

Tags

laravelamazons3awsuploadcdnaws-s3content delivery networkAssets Upload

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[publiux/laravelcdn

Content Delivery Network (CDN) Package for Laravel

155230.4k](/packages/publiux-laravelcdn)[vinelab/cdn

Content Delivery Network (CDN) Package for Laravel

217240.8k1](/packages/vinelab-cdn)[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)
