Download the PHP package khonik/asset-cdn without Composer
On this page you can find all versions of the php package khonik/asset-cdn. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download khonik/asset-cdn
More information about khonik/asset-cdn
Files in khonik/asset-cdn
Package asset-cdn
Short Description Fork from https://github.com/arubacao/asset-cdn
License MIT
Homepage https://github.com/khorevnikita/asset-cdn
Informations about the package asset-cdn
Serve Laravel Assets from a Content Delivery Network (CDN)
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
Installation
Install this package via composer:
Also register the service provider:
Only required for Laravel <=5.4
, for Laravel >=5.5
auto-discovery is enabled.
Notes:
arubacao/asset-cdn
is functional and fully tested for Laravel5.4
-8.*
on PHP7.0
,7.1
,7.2
,7.3, 7.4
Configuration
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 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:
2. Publish Config File
3. Edit cdn_url
and filesystem.disk
4. Edit files
in config/asset-cdn.php
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 oneinclude
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 anyjs
orcss
path it can find in thepublic
directory. -
files
Define files that should be available on the CDN.
The following example will match any file that starts withjs/back.app.js
in thepublic
directory.-
extensions
Define filetypes that should be available on the CDN.
The following example will match any file of type*.css
or*.js
in thepublic
directory. patterns
Define patterns for files that should be available on the CDN.
The following example will match any file that starts with lettersa
orb
in thepublic
directory.
-
-
exclude
Any file that matches at least oneexclude
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
filesystem.options
are passed directly to the Filesystem
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.
6. Set Environment Variable USE_CDN
Usage
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.
Pushes assets that have been defined in the config to the CDN. Pushes all assets. Does not delete files on CDN.
Deletes all assets from CDN, independent from config file.
Serving Assets
Replace mix()
with mix_cdn()
.
Replace asset()
with asset_cdn()
.
Credits:
Icon from www.flaticon.com
Unmaintained git repo by Vinelab for inspiration only
Todo's:
- Video Tutorial: How to use S3/Cloudfront
- Write test for
ignoreVCS
finder config - Write test for
ignoreDotFiles
finder config - Extend
CombinedFinderTest