Coder Social home page Coder Social logo

oskarstark / flysystem-bundle Goto Github PK

View Code? Open in Web Editor NEW

This project forked from thephpleague/flysystem-bundle

0.0 1.0 0.0 239 KB

Symfony bundle integrating Flysystem into Symfony 4.2+ applications

Home Page: https://github.com/thephpleague/flysystem

License: MIT License

PHP 100.00%

flysystem-bundle's Introduction

flysystem-bundle

Packagist Version Software license

flysystem-bundle is a Symfony bundle integrating the Flysystem library into Symfony applications.

It provides an efficient abstraction for the filesystem in order to change the storage backend depending on the execution environment (local files in development, cloud storage in production and memory in tests).

Note: you are reading the documentation for flysystem-bundle 3.0, which relies on Flysystem 3.
If you use Flysystem 1.x, use flysystem-bundle 1.x.
If you use Flysystem 2.x, use flysystem-bundle 2.x.
Read the Upgrade guide to learn how to upgrade.

Installation

flysystem-bundle 3.x requires PHP 8.0+ and Symfony 5.4+.

If you need support for a lower PHP/Symfony version, consider using flysystem-bundle 2.x which support Flysystem 3.x and older PHP/Symfony versions.

You can install the bundle using Symfony Flex:

composer require league/flysystem-bundle

Basic usage

The default configuration file created by Symfony Flex provides enough configuration to use Flysystem in your application as soon as you install the bundle:

# config/packages/flysystem.yaml

flysystem:
    storages:
        default.storage:
            adapter: 'local'
            options:
                directory: '%kernel.project_dir%/var/storage/default'

This configuration defines a single storage service (default.storage) based on the local adapter and configured to use the %kernel.project_dir%/var/storage/default directory.

For each storage defined under flysystem.storages, an associated service is created using the name you provide (in this case, a service default.storage will be created). The bundle also creates a named alias for each of these services.

This means you have two way of using the defined storages:

  • either using autowiring, by typehinting against the FilesystemOperator and using the variable name matching one of your storages:

    use League\Flysystem\FilesystemOperator;
    
    class MyService
    {
        private $storage;
        
        // The variable name $defaultStorage matters: it needs to be the camelized version
        // of the name of your storage. 
        public function __construct(FilesystemOperator $defaultStorage)
        {
            $this->storage = $defaultStorage;
        }
        
        // ...
    }

    The same goes for controllers:

    use League\Flysystem\FilesystemOperator;
    
    class MyController
    {
        // The variable name $defaultStorage matters: it needs to be the camelized version
        // of the name of your storage. 
        public function index(FilesystemOperator $defaultStorage)
        {
            // ...
        }
    }
  • or using manual injection, by injecting the service named default.storage inside your services.

Once you have a FilesystemOperator, you can call methods from the Filesystem API to interact with your storage.

Full documentation

  1. Getting started
  2. Cloud storage providers: AsyncAws S3, AWS SDK S3, Azure, Google Cloud Storage, DigitalOcean Spaces, Scaleway Object Storage
  3. Interacting with FTP and SFTP servers
  4. Using a lazy adapter to switch storage backend using an environment variable
  5. Creating a custom adapter

Security Issues

If you discover a security vulnerability within the bundle, please follow our disclosure procedure.

Backward Compatibility promise

This library follows the same Backward Compatibility promise as the Symfony framework: https://symfony.com/doc/current/contributing/code/bc.html

Note: many classes in this bundle are either marked @final or @internal. @internal classes are excluded from any Backward Compatibility promise (you should not use them in your code) whereas @final classes can be used but should not be extended (use composition instead).

flysystem-bundle's People

Contributors

tgalopin avatar lustmored avatar radiergummi avatar airnzspijkn avatar johnstoncode avatar nyholm avatar nspyke avatar tofandel avatar michealmouner avatar maxhelias avatar meyron avatar nclshart avatar pgrimaud avatar qdequippe avatar ker0x avatar tacman avatar ntomka avatar norkunas avatar vincentlanglet avatar broiniac avatar rogamoore avatar kevinpapst avatar johndodev avatar jonag avatar lyrixx avatar bytehead avatar meranote avatar coil avatar bretrzaun avatar mynameisbogdan avatar

Watchers

 avatar

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.