erashdan / laravelfastly
A Laravel wrapper for Fastly SDK
Installs: 4 531
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 1
Forks: 2
Open Issues: 0
Requires
- php: >=7.1.3
- fastly/fastly: ^0.3.0
- illuminate/support: ~5.3.0|~5.4.0|~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0
Requires (Dev)
- orchestra/testbench: ~3.4.2|~3.5.0|~3.6.0|~3.7.0|~3.8.0|^4.0
- phpunit/phpunit: ^5.7|6.2|^7.0
This package is auto-updated.
Last update: 2021-01-30 02:09:59 UTC
README
This is a wrapper around Fastly SDK for Laravel.
Installation
This package can be used in Laravel 5.5 or higher.
You can install the package via composer:
composer require erashdan/laravelfastly
Laravel's package auto discovery will automatically register the service provider for you.
Then you need to publish the configuration to your project:
php artisan vendor:publish --provider="Erashdan\LaravelFastly\FastlyServiceProvider" --tag="config"
And add the key used for the hashing in .env file
FASTLY_API_KEY=GENERATE_KEY_FROM_FASTLY_ACCOUNT
Usage
You can clear the cache from fastly using the Fastly
Facade
Purge by URL
Fastly::purgeUrl('get-url')
The facade also accept an array of URIs to be cleared
Fastly::purgeUrl(['first-url', 'second-url'])
Purge by service id
First you should define services array in configuration fastly.php
'services' => [ 'main' => 'xDp52XsJ5dXLp', ]
You can call fastly
Facades to purge all files by service name.
Fastly::purgeService('main');
Call method
You can request fastly service to cache a specific url by using call
method
Fastly::callUrl('https://erashdan.com');
Purge and call
You can purge specific url and re-cache (call
) it by using purgeAndCall
method
Fastly::purgeAndCall('https://erashdan.com');
Testing
composer test
Credits
TODO
- [x] Build first version.
- [x] Purge by service ID
- [x] Call fastly `call` wrapper.
- [] Implement `call` using URI