Skip to content

Commit b1e7011

Browse files
committed
Write README and start documentation
1 parent 6ed869e commit b1e7011

8 files changed

Lines changed: 173 additions & 2 deletions

File tree

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ sudo: false
55
matrix:
66
include:
77
- php: 7.1
8-
env: SYMFONY_VERSION="4.1.*" COMPOSER_FLAGS="--prefer-lowest"
8+
env: SYMFONY_VERSION="4.2.*" COMPOSER_FLAGS="--prefer-lowest"
99
- php: 7.2
10-
env: SYMFONY_VERSION="4.1.*" CS_FIXER=1
10+
env: SYMFONY_VERSION="4.2.*" CS_FIXER=1
1111
- php: 7.3
1212
env: SYMFONY_VERSION="4.2.*"
1313
fast_finish: true

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,40 @@
11
# flysystem-bundle
2+
3+
[![Build Status](https://travis-ci.org/tgalopin/flysystem-bundle.svg?branch=master)](https://travis-ci.org/tgalopin/flysystem-bundle)
4+
5+
[![SymfonyInsight](https://insight.symfony.com/projects/525fdfa3-d482-4218-b4b9-3c2efc305fac/big.svg)](https://insight.symfony.com/projects/525fdfa3-d482-4218-b4b9-3c2efc305fac)
6+
7+
This repository is a light Symfony bundle integrating the [Flysystem](https://flysystem.thephpleague.com)
8+
library into Symfony applications. It mainly aims at injecting Flysystem instance(s) efficiently into your
9+
Dependency Injection container.
10+
11+
## Installation
12+
13+
flysystem-bundle requires PHP 7.1+ and Symfony 4.2+.
14+
15+
You can install the bundle using Symfony Flex:
16+
17+
```
18+
composer require tgalopin/flysystem-bundle
19+
```
20+
21+
## Documentation
22+
23+
1. [Getting started](https://github.com/tgalopin/flysystem-bundle/blob/master/docs/1-getting-started.md)
24+
2. [Caching](https://github.com/tgalopin/flysystem-bundle/blob/master/docs/2-caching.md)
25+
3. [Using the mount manager](https://github.com/tgalopin/flysystem-bundle/blob/master/docs/3-using-mount-manager.md)
26+
4. [Configuration reference](https://github.com/tgalopin/flysystem-bundle/blob/master/docs/4-configuration-reference.md)
27+
28+
## Security Issues
29+
30+
If you discover a security vulnerability within the bundle, please follow
31+
[our disclosure procedure](https://github.com/tgalopin/flysystem-bundle/blob/master/docs/A-security-disclosure-procedure.md).
32+
33+
## Backward Compatibility promise
34+
35+
This library follows the same Backward Compatibility promise as the Symfony framework:
36+
[https://symfony.com/doc/current/contributing/code/bc.html](https://symfony.com/doc/current/contributing/code/bc.html)
37+
38+
> *Note*: many classes in this library are either marked `@final` or `@internal`.
39+
> `@internal` classes are excluded from any Backward Compatiblity promise (you should not use them in your code)
40+
> whereas `@final` classes can be used but should not be extended (use composition instead).

docs/1-getting-started.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# Getting started
2+
3+
- [Installation](#installation)
4+
- [Basic usage](#basic-usage)
5+
- [Defining multiple filesystems](#defining-multiple-filesystems)
6+
7+
## Installation
8+
9+
flysystem-bundle requires PHP 7.1+ and Symfony 4.2+.
10+
11+
You can install the bundle using Symfony Flex:
12+
13+
```
14+
composer require tgalopin/flysystem-bundle
15+
```
16+
17+
## Basic usage
18+
19+
The default configuration file created by Symfony Flex provides enough configuration to
20+
use Flysystem in your application as soon as you install the bundle:
21+
22+
```yaml
23+
# config/packages/flysystem.yaml
24+
25+
flysystem:
26+
default_filesystem: 'app'
27+
filesystems:
28+
app:
29+
adapter: 'flysystem.adapter.local'
30+
```
31+
32+
This configuration creates a single filesystem service, configured using the local adapter in the `storge` directory,
33+
and provides this service for autowiring using the `League\Flysystem\FilesystemInterface` interface.
34+
This autowiring will target the default filesystem defined in the bundle configuration.
35+
36+
This means that if you are using autowiring, you can typehint `League\Flysystem\FilesystemInterface` in any
37+
of your services to get the default filesystem:
38+
39+
```php
40+
use League\Flysystem\FilesystemInterface;
41+
42+
class MyService
43+
{
44+
private $filesystem;
45+
46+
public function __construct(FilesystemInterface $filesystem)
47+
{
48+
$this->filesystem = $filesystem;
49+
}
50+
51+
// ...
52+
}
53+
```
54+
55+
The same goes for controllers:
56+
57+
```php
58+
use League\Flysystem\FilesystemInterface;
59+
60+
class MyController
61+
{
62+
public function index(FilesystemInterface $filesystem)
63+
{
64+
// ...
65+
}
66+
}
67+
```
68+
69+
If you are not using autowiring, you can inject the `flysystem` service into your services
70+
manually to get the default filesystem.
71+
72+
## Defining multiple filesystems
73+
74+
Using a single filesystem is good way to get up and running quickly, but it is often useful to
75+
create multiple instances of Flysystem in order to manage different filesystems.
76+
77+
This bundle provides this ability using `named aliases`: by leveraging the variable name in addition to
78+
the interface name, autowiring is able to inject the proper filesystem you want in your services.
79+
80+
This means that if you are using autowiring, you can create multiple filesystems in the configuration of the
81+
bundle and typehint `League\Flysystem\FilesystemInterface` with a variable having the same name as your filesystem
82+
name to get this specific filesystem:
83+
84+
```yaml
85+
# config/packages/flysystem.yaml
86+
87+
flysystem:
88+
default_filesystem: 'app'
89+
filesystems:
90+
app:
91+
adapter: 'flysystem.adapter.local'
92+
93+
# Defines an additional filesystem named "myFilesystem"
94+
myFilesystem:
95+
adapter: 'flysystem.adapter.local'
96+
```
97+
98+
```php
99+
use League\Flysystem\FilesystemInterface;
100+
101+
class MyController
102+
{
103+
public function index(FilesystemInterface $fs, FilesystemInterface $myFilesystem)
104+
{
105+
// $fs is referencing the default filesystem ("app") because the variable name is not a filesystem name
106+
// $myFilesystem is referencing the "myFilesystem" filesystem
107+
}
108+
}
109+
```
110+
111+
If you are not using autowiring, you can inject the `flysystem.filesystem.<filesystem-name>` service into
112+
your services manually to get a specific filesystem (for instance here: `flysystem.filesystem.myFilesystem`).

docs/2-caching.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Caching

docs/3-using-mount-manager.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Using the mount manager

docs/4-configuration-reference.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Configuration reference
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Security issue disclosure procedure
2+
3+
If you think that you have found a security issue in flysystem-bundle, don't use the bug tracker and
4+
don't publish it publicly. Instead, all security issues must be sent to galopintitouan [at] gmail.com.
5+
6+
For each report, the core maintainers of flysystem-bundle will first try to confirm the vulnerability.
7+
When it is confirmed, we will work on a solution following these steps:
8+
9+
1. Send an acknowledgement to the reporter;
10+
2. Work on a patch in a dedicated private repository;
11+
3. Get a CVE identifier from [mitre.org](https://cveform.mitre.org/);
12+
4. Send the patch to the reporter for review;
13+
5. Apply the patch to all maintained versions of flysystem-bundle;
14+
6. Package new versions for all affected versions;
15+
7. Update the [public security advisories database](https://github.com/FriendsOfPHP/security-advisories)
16+
maintained by the FriendsOfPHP organization.

src/DependencyInjection/FlysystemExtension.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ public function load(array $configs, ContainerBuilder $container)
8080

8181
if ($config['default_filesystem'] === $fsName) {
8282
$container->setAlias(FilesystemInterface::class, 'flysystem.filesystem.'.$fsName)->setPublic(false);
83+
$container->setAlias('flysystem', 'flysystem.filesystem.'.$fsName)->setPublic(false);
8384
}
8485
}
8586
}

0 commit comments

Comments
 (0)