Skip to content

Commit 0445ce0

Browse files
committed
Improve documentation
1 parent 60823f8 commit 0445ce0

7 files changed

Lines changed: 105 additions & 43 deletions

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ library into Symfony applications. It provides an efficient abstraction for the
1111
for instance to use local files in development and a cloud storage in production or to use a memory
1212
filesystem in tests to increase their speed.
1313

14-
This bundle relies on **named aliases** (introduced in Symfony 4.2) in order to create and configure
15-
multiple filesystems and still follow the best practices of software architecture (SOLID principles).
14+
This bundle relies on
15+
[named aliases](https://symfony.com/doc/current/service_container/autowiring.html#dealing-with-multiple-implementations-of-the-same-type)
16+
(introduced in Symfony 4.2) in order to create and configure multiple filesystems while still
17+
following the best practices of software architecture (SOLID principles).
1618

1719
## Installation
1820

@@ -29,15 +31,18 @@ composer require league/flysystem-bundle
2931
1. [Getting started](https://github.com/thephpleague/flysystem-bundle/blob/master/docs/1-getting-started.md)
3032
2. Cloud storage providers:
3133
[Azure](https://github.com/thephpleague/flysystem-bundle/blob/master/docs/2-cloud-storage-providers.md#azure),
32-
[AWS S3](https://github.com/thephpleague/flysystem-bundle/blob/master/docs/2-cloud-storage-providers.md#aws),
34+
[AWS S3](https://github.com/thephpleague/flysystem-bundle/blob/master/docs/2-cloud-storage-providers.md#aws-s3),
3335
[DigitalOcean Spaces](https://github.com/thephpleague/flysystem-bundle/blob/master/docs/2-cloud-storage-providers.md#digitalocean-spaces),
3436
[Scaleway Object Storage](https://github.com/thephpleague/flysystem-bundle/blob/master/docs/2-cloud-storage-providers.md#scaleway-object-storage),
3537
[Google Cloud Storage](https://github.com/thephpleague/flysystem-bundle/blob/master/docs/2-cloud-storage-providers.md#google-cloud-storage),
3638
[Rackspace](https://github.com/thephpleague/flysystem-bundle/blob/master/docs/2-cloud-storage-providers.md#rackspace),
3739
[WebDAV](https://github.com/thephpleague/flysystem-bundle/blob/master/docs/2-cloud-storage-providers.md#webdav)
3840
3. [Interacting with FTP and SFTP servers](https://github.com/thephpleague/flysystem-bundle/blob/master/docs/3-interacting-with-ftp-and-sftp-servers.md)
3941
4. [Caching metadata in Symfony cache](https://github.com/thephpleague/flysystem-bundle/blob/master/docs/4-caching-metadata-in-symfony-cache.md)
40-
5. [Configuration reference](https://github.com/thephpleague/flysystem-bundle/blob/master/docs/5-configuration-reference.md)
42+
5. [Creating a custom adapter](https://github.com/thephpleague/flysystem-bundle/blob/master/docs/5-creating-a-custom-adapter.md)
43+
44+
A. [Security issue disclosure procedure](https://github.com/thephpleague/flysystem-bundle/blob/master/docs/A-security-disclosure-procedure.md)
45+
B. [Configuration reference](https://github.com/thephpleague/flysystem-bundle/blob/master/docs/B-configuration-reference.md)
4146

4247
## Security Issues
4348

docs/1-getting-started.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,7 @@ flysystem:
157157

158158
This configuration will swap every reference to the `users.storage` service (or to the
159159
`FilesystemInterface $usersStorage` typehint) from a local adapter to a memory one during tests.
160+
161+
## Next
162+
163+
[Cloud storage providers](https://github.com/thephpleague/flysystem-bundle/blob/master/docs/2-cloud-storage-providers.md)

docs/2-cloud-storage-providers.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ One of the core feature of Flysystem is its ability to interact easily with remo
44
including many cloud storage providers. This bundle provides the same level of support for these
55
cloud providers by providing corresponding adapters in the configuration.
66

7+
* [Azure](#azure)
8+
* [AWS S3](#aws-s3)
9+
* [DigitalOcean Spaces](#digitalocean-spaces)
10+
* [Scaleway Object Storage](#scaleway-object-storage)
11+
* [Google Cloud Storage](#google-cloud-storage)
12+
* [Rackspace](#rackspace)
13+
* [WebDAV](#webdav)
14+
715
## Azure
816

917
### Installation
@@ -27,7 +35,7 @@ flysystem:
2735
prefix: 'optional/path/prefix'
2836
```
2937
30-
## AWS
38+
## AWS S3
3139
3240
### Installation
3341
@@ -150,3 +158,7 @@ flysystem:
150158
prefix: 'optional/path/prefix'
151159
use_stream_copy: false
152160
```
161+
162+
## Next
163+
164+
[Interacting with FTP and SFTP servers](https://github.com/thephpleague/flysystem-bundle/blob/master/docs/3-interacting-with-ftp-and-sftp-servers.md)

docs/3-interacting-with-ftp-and-sftp-servers.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Interacting with FTP and SFTP servers
22

3-
Flysystem is able to interact using the same FilesystemInterface with FTP and SFTP servers.
4-
To configure this bundle for this usage, you can rely on adapters in the same way you would
3+
Flysystem is able to interact with FTP and SFTP servers using the same FilesystemInterface.
4+
To configure this bundle for such usage, you can rely on adapters in the same way you would
55
for other storages.
66

77
## FTP
@@ -56,3 +56,7 @@ flysystem:
5656
root: '/path/to/root'
5757
timeout: 10
5858
```
59+
60+
## Next
61+
62+
[Caching metadata in Symfony cache](https://github.com/thephpleague/flysystem-bundle/blob/master/docs/4-caching-metadata-in-symfony-cache.md)
Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
# Caching metadata in Symfony cache
22

3+
[Read the associated library documentation](https://flysystem.thephpleague.com/docs/advanced/caching/)
4+
35
Networking and I/O are often the source of performance problems in applications.
46
On top of this, Flysystem generally aims to be as reliable as possible, which
57
means it will often check and validate operations before they are done. This
68
involves an additional overhead on top of the classical slowness of I/O.
79

810
When your application needs to scale, you may need to cache metadata in order to
9-
improve performances on this level. To do this, you can use the `cache` adapter
10-
in this bundle.
11+
improve performances on this level. To do this, you can use the `cache` adapter.
12+
13+
> *Note:* this adapter caches anything but the file content. This keeps the cache
14+
> small enough to be beneficial and covers all the file system inspection operations.
1115
1216
### Installation
1317

@@ -17,71 +21,68 @@ composer require league/flysystem-cached-adapter
1721

1822
### Usage
1923

20-
```yaml
21-
# config/packages/flysystem.yaml
24+
The cache adapter works using a source storage (from which it will read the uncached data)
25+
and a [Symfony cache pool](https://symfony.com/doc/current/reference/configuration/framework.html#pools).
2226

23-
flysystem:
24-
storages:
25-
users.storage.source:
26-
adapter: 'aws'
27-
options:
28-
client: 'aws_client_service'
29-
bucket: 'bucket_name'
30-
prefix: 'optional/path/prefix'
27+
Most of the time you are only going to need one of two possibilities:
3128

32-
users.storage:
33-
adapter: 'cache'
34-
options:
35-
store: 'psr6_cache_pool' # A service ID implementing Psr\Cache\CacheItemPoolInterface
36-
source: 'users.storage.source'
37-
```
38-
39-
However, this configuration is generic. Most of the time you are only
40-
going to need one of two possibilities:
41-
42-
* memory cache: this cache will expire at the end of the current CLI process or
43-
HTTP request ;
44-
* persistant cache: this cache will only expire when you clear it ;
29+
* in-memory cache (will expire at the end of the CLI process or HTTP request) ;
30+
* persistant cache (will stay persistent in a cache backend) ;
4531

4632
#### Memory caching
4733

48-
To enable memory cache, you can create a dedicated service based on the Symfony
49-
Cache component:
34+
To use in-memory caching, you can create a dedicated Symfony cache pool:
5035

5136
```yaml
5237
# config/packages/flysystem.yaml
5338

54-
services:
55-
users.storage.cache:
56-
class: 'Symfony\Component\Cache\Adapter\ArrayAdapter'
39+
framework:
40+
cache:
41+
pools:
42+
cache.users.storage:
43+
adapter: cache.adapter.array
44+
default_lifetime: 3600
5745

5846
flysystem:
5947
storages:
60-
# ...
48+
users.storage.source:
49+
adapter: 'aws'
50+
options:
51+
client: 'aws_client_service'
52+
bucket: 'bucket_name'
53+
prefix: 'optional/path/prefix'
6154

6255
users.storage:
6356
adapter: 'cache'
6457
options:
65-
store: 'users.storage.cache'
58+
store: 'cache.users.storage'
6659
source: 'users.storage.source'
6760
```
6861
6962
#### Persistent caching
7063
71-
To enable persistent cache, you can either define your own service in the same way
72-
as the memory cache, or rely on the `cache.app` service provided automatically by
73-
Symfony:
64+
To use persistent caching, you can either create a dedicated Symfony cache pool
65+
or use the pool `cache.app` which is defined by default by Symfony:
7466

7567
```yaml
7668
# config/packages/flysystem.yaml
7769
7870
flysystem:
7971
storages:
80-
# ...
72+
users.storage.source:
73+
adapter: 'aws'
74+
options:
75+
client: 'aws_client_service'
76+
bucket: 'bucket_name'
77+
prefix: 'optional/path/prefix'
8178
8279
users.storage:
8380
adapter: 'cache'
8481
options:
8582
store: 'cache.app'
8683
source: 'users.storage.source'
8784
```
85+
86+
## Next
87+
88+
[Configuration reference](https://github.com/thephpleague/flysystem-bundle/blob/master/docs/5-configuration-reference.md)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Creating a custom adapter
2+
3+
[Read the associated library documentation](https://flysystem.thephpleague.com/docs/advanced/creating-an-adapter/)
4+
5+
If you have highly specific requirements, you may need to create your own
6+
Flysystem adapter. To do so, you first need to create the adapter code itself
7+
and then use it in your storages configuration.
8+
9+
## Creating the adapter class
10+
11+
A Flysystem adapter is a class implementing the `League\Flysystem\AdapterInterface` inteface.
12+
To learn all the details about how to create this class, you can read the
13+
[library documentation](https://flysystem.thephpleague.com/docs/advanced/creating-an-adapter/).
14+
15+
You can create this class everywhere you want in your application. We usually recommend a clear
16+
namespace and class name such as `App\Flysystem\MyCustomAdapter`.
17+
18+
## Using the adapter in a storage configuration
19+
20+
To use the adapter inside your storages configuration, you need to register your newly created
21+
as a service. Fortunately, in most Symfony 4.2+ applications, this is done automatically by Symfony.
22+
23+
> *Note:* if you disabled autodiscovery, you can register manually your adapter as a normal service
24+
> and use the ID your registered instead of the class name in the next YAML examples.
25+
26+
Once created and (automatically) registered as a service, you can reference your adapter inside your
27+
storages:
28+
29+
```yaml
30+
# config/packages/flysystem.yaml
31+
32+
flysystem:
33+
storages:
34+
users.storage:
35+
adapter: 'App\Flysystem\MyCustomAdapter'
36+
```
File renamed without changes.

0 commit comments

Comments
 (0)