Skip to content
This repository was archived by the owner on Jan 4, 2021. It is now read-only.

erashdan/laravel-fastly

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fastly Laravel Build Status

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages