Giter Club home page Giter Club logo

laravel-cloudfront's Introduction

CloudFront Package for Laravel

Latest Version on Packagist GitHub Workflow Status StyleCI Scrutinizer Code Quality Total Downloads Discord License

This is a wrapper package for AWS CloudFront. Please note that while this package is used in production environments and is completely functional, it currently only focuses on cache invalidations.

PRs & ideas are more than welcome! 🙏🏼

laravel-cloudfront package image

💡 Usage

use Meema\CloudFront\Facades\CloudFront;
use Meema\CloudFront\Jobs\InvalidateCache;

// run any of the following CloudFront methods:
$client = CloudFront::getClient(); // exposes the AWS CloudFront client

$paths = ['/some-path.jpg', '/another/path.png'];
$result = CloudFront::invalidate($paths, string $distributionId = null);

// invalidates everything, which is the equivalent to a item path of `/*`.
$result = CloudFront::reset();

$message = CloudFront::getInvalidation(string $invalidationId, string $distributionId = null);
$messages = CloudFront::listInvalidations(string $distributionId = null);

// it's recommended to invalidate your cache using a job
dispatch(new InvalidateCache($path.'*')); // you may want to add a '*'-wildcard at the end of your path if you whitelisted any query parameters

Please note, object invalidations typically take from 60 to 300 seconds to complete. You can check the status of an invalidation by viewing your distribution from the CloudFront console.

🐙 Installation

You can install the package via composer:

composer require meema/laravel-cloudfront

The package will automatically register itself.

Next, publish the config file with:

php artisan vendor:publish --provider="Meema\CloudFront\Providers\CloudFrontServiceProvider" --tag="config"

Next, please add the following keys their values to your .env file.

AWS_ACCESS_KEY_ID=xxxxxxx
AWS_SECRET_ACCESS_KEY=xxxxxxx
AWS_CLOUDFRONT_DISTRIBUTION_ID=xxxxxxx

The following is the content of the published config file:

return [
    /**
     * IAM Credentials from AWS.
     */
    'credentials' => [
        'key' => env('AWS_ACCESS_KEY_ID'),
        'secret' => env('AWS_SECRET_ACCESS_KEY'),
    ],

    'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),

    /**
     * Specify the version of the CloudFront API you would like to use.
     * Please only adjust this value if you know what you are doing.
     */
    'version' => 'latest',

    /**
     * Specify the CloudFront Distribution ID.
     * Example format: EBCYQAQALNSKL
     */
    'distribution_id' => env('AWS_CLOUDFRONT_DISTRIBUTION_ID'),

];

🧪 Testing

composer test

📈 Changelog

Please see our releases page for more information on what has changed recently.

💪🏼 Contributing

Please see CONTRIBUTING for details.

🏝 Community

For help, discussion about best practices, or any other conversation that would benefit from being searchable:

Laravel CloudFront on GitHub

For casual chit-chat with others using this package:

Join the Meema Discord Server

🚨 Security

Please review our security policy on how to report security vulnerabilities.

🙏🏼 Credits

📄 License

The MIT License (MIT). Please see LICENSE for more information.

Made with ❤️ by Meema, Inc.

laravel-cloudfront's People

Contributors

chrisbbreuer avatar glennmichael123 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

laravel-cloudfront's Issues

What is minimum required version of Laravel and/or Lumen?

How could we help you?

I am using Laravel/Lumen v5.8, yes very far behind, but that's what it is.

this package's CloudFront::invalidate() fails at line 33 of CloudFrontManager. There is no $this->config[] in Illuminate\Support\Manager. But if line 33 is changed from

$config = $this->config['cloudfront'];

to

$config = config('cloudfront');

using the helper function, it works fine. Could it be just the difference between Laravel and Lumen?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.