Laravel Flysystem - a Flysystem bridge for Laravel.

Overview

Laravel Flysystem

Laravel Flysystem was created by, and is maintained by Graham Campbell, and is a Flysystem bridge for Laravel. It utilises my Laravel Manager package. Feel free to check out the change log, releases, security policy, license, code of conduct, and contribution guidelines.

Banner

Build Status StyleCI Status Software License Packagist Downloads Latest Version

Installation

Laravel Flysystem requires PHP 7.2-8.1. This particular version supports Laravel 6-8.

Flysystem L5.1 L5.2 L5.3 L5.4 L5.5 L5.6 L5.7 L5.8 L6 L7 L8
3.7
4.1
5.3
6.3
7.1

To get the latest version, simply require the project using Composer:

$ composer require "graham-campbell/flysystem:^7.1"

There are also some additional dependencies you will need to install for some of the features:

  • The AwsS3 adapter requires league/flysystem-aws-s3-v3 (^1.0).
  • The Azure adapter requires league/flysystem-azure-blob-storage (^0.1.6).
  • The Dropbox adapter requires spatie/flysystem-dropbox (^1.0).
  • The GoogleCloudStorage adapter requires superbalist/flysystem-google-storage (^7.2).
  • The GridFS adapter requires league/flysystem-gridfs (^1.0) and alcaeus/mongo-php-adapter (^1.1).
  • The Sftp adapter requires league/flysystem-sftp (^1.0).
  • The WebDav adapter requires league/flysystem-webdav (^1.0).
  • The ZipAdapter adapter requires league/flysystem-ziparchive (^1.0).
  • The adapter caching support requires league/flysystem-cached-adapter (^1.0).
  • The eventable filesystem support requires league/flysystem-eventable-filesystem (^1.0).

Once installed, if you are not using automatic package discovery, then you need to register the GrahamCampbell\Flysystem\FlysystemServiceProvider service provider in your config/app.php.

You can also optionally alias our facade:

        'Flysystem' => GrahamCampbell\Flysystem\Facades\Flysystem::class,

Configuration

Laravel Flysystem requires connection configuration.

To get started, you'll need to publish all vendor assets:

$ php artisan vendor:publish

This will create a config/flysystem.php file in your app that you can modify to set your configuration. Also, make sure you check for changes to the original config file in this package between releases.

There are three config options:

Default Connection Name

This option ('default') is where you may specify which of the connections below you wish to use as your default connection for all work. Of course, you may use many connections at once using the manager class. The default value for this setting is 'local'.

Flysystem Connections

This option ('connections') is where each of the connections are setup for your application. Examples of configuring each supported driver are included in the config file, which you should have "published". You can of course have multiple connections per driver.

Flysystem Cache

This option ('cache') is where each of the cache configurations setup for your application. There are currently two drivers: illuminate and adapter. Examples of configuration are included. You can of course have multiple connections per driver as shown.

Usage

FlysystemManager

This is the class of most interest. It is bound to the ioc container as 'flysystem' and can be accessed using the Facades\Flysystem facade. This class implements the ManagerInterface by extending AbstractManager. The interface and abstract class are both part of my Laravel Manager package, so you may want to go and checkout the docs for how to use the manager class over at that repo. Note that the connection class returned will always be an instance of a class that implements \League\Flysystem\FilesystemInterface which will be \League\Flysystem\Filesystem by default.

Facades\Flysystem

This facade will dynamically pass static method calls to the 'flysystem' object in the ioc container which by default is the FlysystemManager class.

FlysystemServiceProvider

This class contains no public methods of interest. This class should be added to the providers array in config/app.php. This class will setup ioc bindings.

Real Examples

Here you can see an example of just how simple this package is to use. Out of the box, the default adapter is local, and it will just work straight away:

use GrahamCampbell\Flysystem\Facades\Flysystem;
// you can alias this in config/app.php if you like

Flysystem::put('hi.txt', 'foo');
// we're done here - how easy was that, it just works!

Flysystem::read('hi.txt'); // this will return foo

The flysystem manager will behave like it is a \League\Flysystem\Filesystem class. If you want to call specific connections, you can do with the connection method:

use GrahamCampbell\Flysystem\Facades\Flysystem;

// note the foo connection does not ship with this package, it's hypothetical
Flysystem::connection('foo')->put('test.txt', 'bar');

// now we can read that file
Flysystem::connection('foo')->read('test.txt'); // this will return bar

With that in mind, note that:

use GrahamCampbell\Flysystem\Facades\Flysystem;

// writing this:
Flysystem::connection('local')->read('test.txt');

// is identical to writing this:
Flysystem::read('test.txt');

// and is also identical to writing this:
Flysystem::connection()->read('test.txt');

// this is because the local connection is configured to be the default
Flysystem::getDefaultConnection(); // this will return local

// we can change the default connection
Flysystem::setDefaultConnection('foo'); // the default is now foo

If you prefer to use dependency injection over facades like me, then you can easily inject the manager like so:

use GrahamCampbell\Flysystem\FlysystemManager;
use Illuminate\Support\Facades\App; // you probably have this aliased already

class Foo
{
    protected $flysystem;

    public function __construct(FlysystemManager $flysystem)
    {
        $this->flysystem = $flysystem;
    }

    public function bar()
    {
        $this->flysystem->read('test.txt');
    }
}

App::make('Foo')->bar();

For more information on how to use the \League\Flysystem\Filesystem class we are calling behind the scenes here, check out the docs at https://flysystem.thephpleague.com/docs/usage/filesystem-api/, and the manager class at https://github.com/GrahamCampbell/Laravel-Manager#usage.

Further Information

There are other classes in this package that are not documented here. This is because they are not intended for public use and are used internally by this package.

Security

If you discover a security vulnerability within this package, please send an email to [email protected]. All security vulnerabilities will be promptly addressed. You may view our full security policy here.

License

Laravel Flysystem is licensed under The MIT License (MIT).

For Enterprise

Available as part of the Tidelift Subscription

The maintainers of graham-campbell/flysystem and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.

You might also like...
A light weight laravel package that facilitates dealing with arabic concepts using a set of classes and methods to make laravel speaks arabic

A light weight laravel package that facilitates dealing with arabic concepts using a set of classes and methods to make laravel speaks arabic! concepts like , Hijri Dates & Arabic strings and so on ..

Jetstrap is a lightweight laravel 8 package that focuses on the VIEW side of Jetstream / Breeze package installed in your Laravel application

A Laravel 8 package to easily switch TailwindCSS resources generated by Laravel Jetstream and Breeze to Bootstrap 4.

Laravel Jetstream is a beautifully designed application scaffolding for Laravel.

Laravel Jetstream is a beautifully designed application scaffolding for Laravel. Jetstream provides the perfect starting point for your next Laravel application and includes login, registration, email verification, two-factor authentication, session management, API support via Laravel Sanctum, and optional team management.

Laravel Larex lets you translate your whole Laravel application from a single CSV file.
Laravel Larex lets you translate your whole Laravel application from a single CSV file.

Laravel Larex Translate Laravel Apps from a CSV File Laravel Larex lets you translate your whole Laravel application from a single CSV file. You can i

A Laravel package that adds a simple image functionality to any Laravel model
A Laravel package that adds a simple image functionality to any Laravel model

Laraimage A Laravel package that adds a simple image functionality to any Laravel model Introduction Laraimage served four use cases when using images

A Laravel extension for using a laravel application on a multi domain setting
A Laravel extension for using a laravel application on a multi domain setting

Laravel Multi Domain An extension for using Laravel in a multi domain setting Description This package allows a single Laravel installation to work wi

Laravel router extension to easily use Laravel's paginator without the query string

🚨 THIS PACKAGE HAS BEEN ABANDONED 🚨 We don't use this package anymore in our own projects and cannot justify the time needed to maintain it anymore.

Laravel application project as Sheina Online Store backend to be built with Laravel and VueJS

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Postgis extensions for laravel. Aims to make it easy to work with geometries from laravel models.

Laravel Wrapper for PostgreSQL's Geo-Extension Postgis Features Work with geometry classes instead of arrays. $model-myPoint = new Point(1,2); //lat

Comments
  • Add 'use_path_style_endpoint' parameter to AwsS3Connector class

    Add 'use_path_style_endpoint' parameter to AwsS3Connector class

    Hello

    I am using the open source object storage server Minio in one of my projects.

    I tried to configure it as the Laravel documentation explains. However, I encountered a problem.

    https://laravel.com/docs/8.x/homestead#configuring-minio

    Laravel, by default uses the 'filesystems.php' configuration file, not 'flysystem.php' like we do, to set the population parameters.

    Among the values in the filesystems file, there is a very important one used to configure the plugin: 'use_path_style_endpoint'.

    However, in your implementation I can see, you are ommitting this parameter inside the 'AwsS3Connector' class, so even if I add it to the "flysystem" file, it still wouldn't get used.

    Could you please add this piece of code inside the 'getAuth' function in the AwsS3Connector class to include the "use_path_style_endpoint" variable?

            if (array_key_exists('use_path_style_endpoint', $config)) {
                $auth['use_path_style_endpoint'] = $config['use_path_style_endpoint'];
            }
    

    Perhaps there are other important parameters I'm not aware of, but for now, I've found that this one is missing and it would be great to have it included in your plugin for code maintenance's sake.

    Thank you very much.

    opened by vitxu83 0
Releases(v8.0.0)
Owner
Graham Campbell
OSS Maintainer | Laravel | StyleCI
Graham Campbell
A Hashids bridge for Laravel

Laravel Hashids A Hashids bridge for Laravel. // Encode integers. Hashids::encode(4815162342); // Decode strings. Hashids::decode('1LLb3b4ck'); // D

Vincent Klaiber 1.8k Dec 29, 2022
Flysystem storage with local metadata storage for speed and manageability.

Laravel Filer This project was started to scratch my itch on our growing Laravel site: Metadata for all files is stored in a local repository - Suppor

Nick Vahalik 16 May 23, 2022
List of 77 languages for Laravel Framework 4, 5, 6, 7 and 8, Laravel Jetstream , Laravel Fortify, Laravel Breeze, Laravel Cashier, Laravel Nova and Laravel Spark.

Laravel Lang In this repository, you can find the lang files for the Laravel Framework 4/5/6/7/8, Laravel Jetstream , Laravel Fortify, Laravel Cashier

Laravel Lang 6.9k Jan 2, 2023
⚡ Laravel Charts — Build charts using laravel. The laravel adapter for Chartisan.

What is laravel charts? Charts is a Laravel library used to create Charts using Chartisan. Chartisan does already have a PHP adapter. However, this li

Erik C. Forés 31 Dec 18, 2022
Laravel Kickstart is a Laravel starter configuration that helps you build Laravel websites faster.

Laravel Kickstart What is Laravel Kickstart? Laravel Kickstart is a Laravel starter configuration that helps you build Laravel websites faster. It com

Sam Rapaport 46 Oct 1, 2022
Laravel User Activity Log - a package for Laravel 8.x that provides easy to use features to log the activities of the users of your Laravel app

Laravel User Activity Log - a package for Laravel 8.x that provides easy to use features to log the activities of the users of your Laravel app

null 9 Dec 14, 2022
Laravel Segment is an opinionated, approach to integrating Segment into your Laravel application.

Laravel Segment Laravel Segment is an opinionated, approach to integrating Segment into your Laravel application. Installation You can install the pac

Octohook 13 May 16, 2022
Laravel Sanctum support for Laravel Lighthouse

Lighthouse Sanctum Add Laravel Sanctum support to Lighthouse Requirements Installation Usage Login Logout Register Email Verification Forgot Password

Daniël de Wit 43 Dec 21, 2022
Bring Laravel 8's cursor pagination to Laravel 6, 7

Laravel Cursor Paginate for laravel 6,7 Installation You can install the package via composer: composer require vanthao03596/laravel-cursor-paginate U

Pham Thao 9 Nov 10, 2022
A package that uses blade templates to control how markdown is converted to HTML inside Laravel, as well as providing support for markdown files to Laravel views.

Install Install via composer. $ composer require olliecodes/laravel-etched-blade Once installed you'll want to publish the config. $ php artisan vendo

Ollie Codes 19 Jul 5, 2021