PHPackages                             steveeakin/asset-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. steveeakin/asset-cdn

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

steveeakin/asset-cdn
====================

Serve Laravel Assets from a Content Delivery Network (CDN)

0.2.5(5y ago)01.2kMITPHPPHP ^7.0|^8.0

Since Mar 3Pushed 4y agoCompare

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

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

[![](https://raw.githubusercontent.com/arubacao/asset-cdn/master/asset-cdn.png)](https://raw.githubusercontent.com/arubacao/asset-cdn/master/asset-cdn.png)

[![Latest Stable Version](https://camo.githubusercontent.com/35ed6adeb09cc8ffd4cb50fe37aa70b6a461fab035eef987e151c2129c19231a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f617275626163616f2f61737365742d63646e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/arubacao/asset-cdn)[![GitHub Workflow Status](https://camo.githubusercontent.com/6705b373f5e306c96e8c18f8d73266adc6fdf6413109f182b2e76bdcd593d039/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f617275626163616f2f61737365742d63646e2f52756e25323054657374733f7374796c653d666c61742d737175617265)](https://github.com/arubacao/asset-cdn/actions?query=workflow%3A%22Run+Tests%22)[![Codecov](https://camo.githubusercontent.com/aaac5fc2a84011bdab36df7b2b63cb33e98b1eb44efa3bb0777f2781b9c28cc1/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f617275626163616f2f61737365742d63646e2e7376673f7374796c653d666c61742d737175617265)](https://codecov.io/gh/arubacao/asset-cdn)[![Quality Score](https://camo.githubusercontent.com/562fe4e866b85280bb376a78fd0fb8e1716287eb631f432727ae8b6d13bec079/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f617275626163616f2f61737365742d63646e2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/arubacao/asset-cdn)[![Total Downloads](https://camo.githubusercontent.com/772fb8c5b845d1391347f90480795031067a751468e8f58754799b4ea05cb1f0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f617275626163616f2f61737365742d63646e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/arubacao/asset-cdn)

**Serve Laravel Assets from a Content Delivery Network (CDN)**

Introduction
------------

[](#introduction)

This package lets you **push**, **sync**, **delete** and **serve** assets to/from a CDN of your choice e.g. AWS Cloudfront.
It adds helper methods **`mix_cdn()`** and **`asset_cdn()`**.

#### Simple Illustration

[](#simple-illustration)

```
>>> env('USE_CDN')
=> true
```

```
$ php artisan asset-cdn:sync
```

```
// head.blade.php

```

```

```

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

[](#installation)

Install this package via composer:

```
$ composer require arubacao/asset-cdn
```

Also register the service provider:
*Only required for Laravel `=5.5` [auto-discovery](composer.json#L45) is enabled.*

```
// config/app.php

'providers' => [
    // Other Service Providers
    \Arubacao\AssetCdn\AssetCdnServiceProvider::class,
],
```

Notes:

- `arubacao/asset-cdn` is functional and fully tested for Laravel `5.4` - `8.*` on PHP `7.0`, `7.1`, `7.2`, `7.3, 7.4`

Configuration
-------------

[](#configuration)

#### 1. Configure Filesystem

[](#1-configure-filesystem)

*Only required if you plan to manage your assets via the provided commands: `asset-cdn:push`, `asset-cdn:sync`, `asset-cdn:empty`*

`arubacao/asset-cdn` utilizes [Laravel's Filesystem](https://laravel.com/docs/5.6/filesystem) to **push**, **sync**, **delete** assets to/from the CDN of your choice. Therefore, you have to configure and define a filesystem specific for CDN purposes. Please follow the official documentation.

If you plan to use AWS S3/Cloudfront you can use this configuration:

```
// config/filesystem.php

'asset-cdn' => [
    'driver' => 's3',
    'key' => env('AWS_ACCESS_KEY_ID'),
    'secret' => env('AWS_SECRET_ACCESS_KEY'),
    'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
    'bucket' => env('AWS_CDN_BUCKET'),
],
```

#### 2. Publish Config File

[](#2-publish-config-file)

```
$ php artisan vendor:publish --provider="Arubacao\AssetCdn\AssetCdnServiceProvider"
```

#### 3. Edit `cdn_url` and `filesystem.disk`

[](#3-edit-cdn_url-and-filesystemdisk)

```
// config/asset-cdn.php

[
    'cdn_url' => 'https://cdn.mysite.com',
    'filesystem' => [
        'disk' => 'asset-cdn',
    ],
]
```

#### 4. Edit `files` in `config/asset-cdn.php`

[](#4-edit-files-in-configasset-cdnphp)

*Only required if you plan to manage your assets via the provided commands: `asset-cdn:push`, `asset-cdn:sync`, `asset-cdn:empty`*

**`files` always assumes a relative path from the `public` directoy**

- `ignoreDotFiles`
    Excludes "hidden" directories and files (starting with a dot).
- `ignoreVCS`
    Ignore version control directories.
- `include`
    **Any** file that matches at least one `include` rule, will be included. **No** file is included by default.

    - `paths`
        Define **paths** that should be available on the CDN.
        The following example will match **any** file in **any** `js` or `css` path it can find in the `public` directory.

        ```
        'include' => [
            'paths' => [
                'js',
                'css'
            ],
        ]

        /*
         * This config would try to find:
         * '/var/www/html/public/js'
         * '/var/www/html/public/css'
         * but also any other 'js' or 'css' path e.g.
         * '/var/www/html/public/vendor/js'
         * '/var/www/html/public/vendor/css'
         * You could explicitly exclude paths later
         */
        ```
    - `files`
        Define **files** that should be available on the CDN.
        The following example will match **any** file that starts with `js/back.app.js` in the `public` directory.

        ```
        'include' => [
            'files' => [
                'js/app.js',
            ],
        ],

        /*
         * This config would try to find:
         * '/var/www/html/public/js/app.js'
         * but also any other file that matches the path + filename e.g.
         * '/var/www/html/public/vendor/js/app.js'
         * You could explicitly exclude these files later
         */
        ```
    - `extensions`
        Define **filetypes** that should be available on the CDN.
        The following example will match **any** file of type `*.css` or `*.js` in the `public` directory.

        ```
        'include' => [
            'extensions' => [
                '*.js',
                '*.css',
            ],
        ],
        ```
    - `patterns`
        Define **patterns** for files that should be available on the CDN.
        The following example will match **any** file that starts with letters `a` or `b` in the `public` directory.

        ```
        /*
         * Patterns can be globs, strings, or regexes
         */

        'include' => [
            'patterns' => [
                '/^[a-b]/i', //  starting with letters a-b
            ],
        ],
        ```
- `exclude`
    **Any** file that matches at least one `exclude` rule, will be excluded. Files that are excluded will **never** be included, even if they have been explicitly included. Rules are identical as described above.

#### 5. Set Additional Configurations for Uploaded Files

[](#5-set-additional-configurations-for-uploaded-files)

`filesystem.options` are passed directly to the [Filesystem](https://github.com/thephpleague/flysystem/blob/1.0.43/src/FilesystemInterface.php#L232)which eventually calls the underlying Storage driver e.g. S3.
Please refer to the corresponding storage driver documentation for available configuration options.
The following example is recommended for AWS S3.

```
// config/asset-cdn.php

[
    'filesystem' => [
        'disk' => 'asset-cdn',
        'options' => [
            'ACL' => 'public-read', // File is available to the public, independent of the S3 Bucket policy
            'CacheControl' => 'max-age=31536000, public', // Sets HTTP Header 'cache-control'. The client should cache the file for max 1 year
        ],
    ],
]
```

#### 6. Set Environment Variable `USE_CDN`

[](#6-set-environment-variable-use_cdn)

```
# .env

USE_CDN=true # Enables asset-cdn
USE_CDN=false # Disables asset-cdn (default)
```

Usage
-----

[](#usage)

#### Commands

[](#commands)

**Recommended**
Sync assets that have been defined in the config to the CDN. Only pushes changes/new assets. Deletes locally removed files on CDN.

```
$ php artisan asset-cdn:sync
```

Pushes assets that have been defined in the config to the CDN. Pushes all assets. Does not delete files on CDN.

```
$ php artisan asset-cdn:push
```

Deletes all assets from CDN, independent from config file.

```
$ php artisan asset-cdn:empty
```

#### Serving Assets

[](#serving-assets)

Replace [`mix()`](https://laravel.com/docs/5.6/helpers#method-mix) with `mix_cdn()`.
Replace [`asset()`](https://laravel.com/docs/5.6/helpers#method-asset) with `asset_cdn()`.

Credits:
--------

[](#credits)

Icon from [www.flaticon.com](http://www.flaticon.com/)
Unmaintained git repo by [Vinelab](https://github.com/Vinelab/cdn) for inspiration only

Todo's:
-------

[](#todos)

- Video Tutorial: How to use S3/Cloudfront
- Write test for `ignoreVCS` finder config
- Write test for `ignoreDotFiles` finder config
- Extend `CombinedFinderTest`

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 97.1% 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 ~171 days

Recently: every ~251 days

Total

7

Last Release

1957d ago

PHP version history (2 changes)0.1.0PHP ^7.0

0.2.5PHP ^7.0|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/6329c756d889e4f3eda204a4755a7092ef8d845af8663bf874e2a8f71ea43868?d=identicon)[steveeakin](/maintainers/steveeakin)

---

Top Contributors

[![arubacao](https://avatars.githubusercontent.com/u/7462542?v=4)](https://github.com/arubacao "arubacao (67 commits)")[![steveeakin](https://avatars.githubusercontent.com/u/4388590?v=4)](https://github.com/steveeakin "steveeakin (2 commits)")

---

Tags

laravelcdncontent delivery networkAWS Cloudfront

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/steveeakin-asset-cdn/health.svg)

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

###  Alternatives

[livewire/volt

An elegantly crafted functional API for Laravel Livewire.

4195.3M84](/packages/livewire-volt)[arubacao/asset-cdn

Serve Laravel Assets from a Content Delivery Network (CDN)

111190.3k](/packages/arubacao-asset-cdn)[gehrisandro/tailwind-merge-laravel

TailwindMerge for Laravel merges multiple Tailwind CSS classes by automatically resolving conflicts between them

341682.2k18](/packages/gehrisandro-tailwind-merge-laravel)[whitecube/laravel-timezones

Store UTC dates in the database and work with custom timezones in the application.

106106.2k](/packages/whitecube-laravel-timezones)[forxer/laravel-gravatar

A library providing easy gravatar integration in a Laravel project.

4235.6k](/packages/forxer-laravel-gravatar)[iteks/laravel-enum

A comprehensive Laravel package providing enhanced enum functionalities, including attribute handling, select array conversions, and fluent facade interactions for robust enum management in Laravel applications.

2516.7k](/packages/iteks-laravel-enum)

PHPackages © 2026

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