You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The package provides the developer the ability to upload his assets (or any public file) to a CDN with a single artisan command.
And then it allows him to switch between the local and the online version of the files.
'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
Usage
Push
Upload assets to CDN
php artisan cdn:push
Empty
Delete assets from CDN
php artisan cdn:empty
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
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
To run the tests, run the following command from the project folder.