Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 3 #115

Merged
merged 8 commits into from
Sep 12, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 27 additions & 10 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,35 @@ jobs:
coverage: none
- name: php-cs-fixer
run: |
wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.19.0/php-cs-fixer.phar -q
wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v3.11.0/php-cs-fixer.phar -q
php php-cs-fixer.phar fix --dry-run --diff

tests-php-7-2-symfony-4-4:
tests-php-8-0-symfony-5-4:
runs-on: ubuntu-latest
env:
SYMFONY_VERSION: 4.4.*
SYMFONY_VERSION: 5.4.*
steps:
- uses: actions/checkout@master
- uses: shivammathur/setup-php@v2
with:
php-version: '7.2'
php-version: '8.0'
coverage: none
- name: PHPUnit
run: |
composer require --no-update symfony/config=$SYMFONY_VERSION symfony/http-kernel=$SYMFONY_VERSION symfony/dependency-injection=$SYMFONY_VERSION symfony/options-resolver=$SYMFONY_VERSION
composer require --no-update --dev symfony/framework-bundle=$SYMFONY_VERSION symfony/yaml=$SYMFONY_VERSION
composer update --prefer-lowest --prefer-dist --no-interaction --no-ansi --no-progress
composer update --prefer-dist --no-interaction --no-ansi --no-progress
php vendor/bin/simple-phpunit

tests-php-7-4-symfony-5-3:
tests-php-8-0-symfony-6-0:
runs-on: ubuntu-latest
env:
SYMFONY_VERSION: 5.3.*
SYMFONY_VERSION: 6.0.*
steps:
- uses: actions/checkout@master
- uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: '8.0'
coverage: none
- name: PHPUnit
run: |
Expand All @@ -54,15 +54,15 @@ jobs:
composer update --prefer-dist --no-interaction --no-ansi --no-progress
php vendor/bin/simple-phpunit

tests-php-8-0-symfony-5-4:
tests-php-8-1-symfony-5-4:
runs-on: ubuntu-latest
env:
SYMFONY_VERSION: 5.4.*
steps:
- uses: actions/checkout@master
- uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
php-version: '8.1'
coverage: none
- name: PHPUnit
run: |
Expand All @@ -87,3 +87,20 @@ jobs:
composer require --no-update --dev symfony/framework-bundle=$SYMFONY_VERSION symfony/yaml=$SYMFONY_VERSION
composer update --prefer-dist --no-interaction --no-ansi --no-progress
php vendor/bin/simple-phpunit

tests-php-8-1-symfony-6-1:
runs-on: ubuntu-latest
env:
SYMFONY_VERSION: 6.1.*
steps:
- uses: actions/checkout@master
- uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
coverage: none
- name: PHPUnit
run: |
composer require --no-update symfony/config=$SYMFONY_VERSION symfony/http-kernel=$SYMFONY_VERSION symfony/dependency-injection=$SYMFONY_VERSION symfony/options-resolver=$SYMFONY_VERSION
composer require --no-update --dev symfony/framework-bundle=$SYMFONY_VERSION symfony/yaml=$SYMFONY_VERSION
composer update --prefer-dist --no-interaction --no-ansi --no-progress
php vendor/bin/simple-phpunit
4 changes: 2 additions & 2 deletions .php_cs.dist → .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
->in(__DIR__)
;

return PhpCsFixer\Config::create()
->setRules(array(
$config = new PhpCsFixer\Config();
return $config->setRules(array(
'@Symfony' => true,
'phpdoc_annotation_without_dot' => false,
))
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ 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 2.0, which relies on Flysystem 2 or Flysystem 3.
> If you use Flysystem 1.X, use [flysystem-bundle 1.X](https://github.com/thephpleague/flysystem-bundle/tree/1.x).
> 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](https://github.com/thephpleague/flysystem-bundle/tree/1.x).
> If you use Flysystem 2.X, use [flysystem-bundle 2.X](https://github.com/thephpleague/flysystem-bundle/tree/2.3.0).
> Read the [Upgrade guide](https://github.com/thephpleague/flysystem-bundle/blob/master/UPGRADE.md) to learn how to upgrade.

## Installation

flysystem-bundle requires PHP 7.2+ and Symfony 4.2+.
flysystem-bundle requires PHP 8.0+ and Symfony 5.4+.

You can install the bundle using Symfony Flex:

Expand Down Expand Up @@ -100,6 +101,7 @@ to interact with your storage.
2. Cloud storage providers:
[AsyncAws S3](https://github.com/thephpleague/flysystem-bundle/blob/master/docs/2-cloud-storage-providers.md#asyncaws-s3),
[AWS SDK S3](https://github.com/thephpleague/flysystem-bundle/blob/master/docs/2-cloud-storage-providers.md#aws-sdk-s3),
[Azure](https://github.com/thephpleague/flysystem-bundle/blob/master/docs/2-cloud-storage-providers.md#azure),
[Google Cloud Storage](https://github.com/thephpleague/flysystem-bundle/blob/master/docs/2-cloud-storage-providers.md#google-cloud-storage),
[DigitalOcean Spaces](https://github.com/thephpleague/flysystem-bundle/blob/master/docs/2-cloud-storage-providers.md#digitalocean-spaces),
[Scaleway Object Storage](https://github.com/thephpleague/flysystem-bundle/blob/master/docs/2-cloud-storage-providers.md#scaleway-object-storage)
Expand Down
16 changes: 16 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,19 @@ In addition to the library updates, the bundle also changed a bit:
* Drop support for Azure, Dropbox, Rackspace and WebDAV adapters (following the main library) ;
* Drop support for null, cache, zip and replicate adapters (following the main library) ;
* Drop support for plugins ;

# Upgrading from 2.0 to 3.0

flysystem-bundle 3.0 relies on Flysystem 3.0, PHP 8.0+ and Flysystem adapters 3.1+.

The changes in this version focus on dropping support for EOL versions of PHP and Symfony and
adding support for Azure Blob Storage.
No new backwards incompatible code changes have been directly introduced by this new bundle version.
As with any major version upgrade, please be sure to test thoroughly.

These changes are;

* Added support for Azure Blob Storage (`league/flysystem-azure-blob-storage ^3.1`)
* Dropped support for PHP 7
* Dropped support of `league/flysystem ^2.0` and older Flysystem adapters `league/flysystem-* ^2.0|3.0.*`
* Dropped support for Symfony 4.2 to 5.3
37 changes: 19 additions & 18 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "league/flysystem-bundle",
"description": "Symfony bundle integrating Flysystem into Symfony 4.2+ applications",
"description": "Symfony bundle integrating Flysystem into Symfony 4.4+ applications",
"type": "symfony-bundle",
"license": "MIT",
"authors": [
Expand All @@ -20,26 +20,27 @@
}
},
"require": {
"php": ">=7.2",
"league/flysystem": "^2.1|^3.0",
"symfony/config": "^4.2|^5.0|^6.0",
"php": ">=8.0",
"league/flysystem": "^3.0",
"symfony/config": "^5.4|^6.0",
"symfony/deprecation-contracts": "^2.1|^3",
"symfony/http-kernel": "^4.2|^5.0|^6.0",
"symfony/dependency-injection": "^4.2|^5.0|^6.0",
"symfony/options-resolver": "^4.2|^5.0|^6.0"
"symfony/http-kernel": "^5.4|^6.0",
"symfony/dependency-injection": "^5.4|^6.0",
"symfony/options-resolver": "^5.4|^6.0"
},
"require-dev": {
"league/flysystem-async-aws-s3": "^2.0|^3.0",
"league/flysystem-aws-s3-v3": "^2.0|^3.0",
"league/flysystem-ftp": "^2.0|^3.0",
"league/flysystem-google-cloud-storage": "^2.0|^3.0",
"league/flysystem-memory": "^2.0|^3.0",
"league/flysystem-sftp-v3": "^2.0|^3.0",
"symfony/dotenv": "^4.2|^5.0|^6.0",
"symfony/framework-bundle": "^4.2|^5.0|^6.0",
"symfony/phpunit-bridge": "^5.2",
"symfony/var-dumper": "^4.1|^5.0|^6.0",
"symfony/yaml": "^4.2|^5.0|^6.0"
"league/flysystem-async-aws-s3": "^3.1",
"league/flysystem-aws-s3-v3": "^3.1",
"league/flysystem-azure-blob-storage": "^3.1",
"league/flysystem-ftp": "^3.1",
"league/flysystem-google-cloud-storage": "^3.1",
"league/flysystem-memory": "^3.1",
"league/flysystem-sftp-v3": "^3.1",
"symfony/dotenv": "^5.4|^6.0",
"symfony/framework-bundle": "^5.4|^6.0",
"symfony/phpunit-bridge": "^5.4|^6.0",
"symfony/var-dumper": "^5.4|^6.0",
"symfony/yaml": "^5.4|^6.0"
},
"conflict": {
"league/flysystem-cached-adapter": "<1.0.9"
Expand Down
24 changes: 24 additions & 0 deletions docs/2-cloud-storage-providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,36 @@ One of the core feature of Flysystem is its ability to interact easily with remo
including many cloud storage providers. This bundle provides the same level of support for these
cloud providers by providing corresponding adapters in the configuration.

* [Azure](#azure)
* [AsyncAws S3](#asyncaws-s3)
* [AWS S3](#aws-sdk-s3)
* [DigitalOcean Spaces](#digitalocean-spaces)
* [Scaleway Object Storage](#scaleway-object-storage)
* [Google Cloud Storage](#google-cloud-storage)

## Azure

### Installation

```
composer require league/flysystem-azure-blob-storage
```

### Usage

```yaml
# config/packages/flysystem.yaml

flysystem:
storages:
users.storage:
adapter: 'azure'
options:
client: 'azure_client_service' # The service ID of the MicrosoftAzure\Storage\Blob\BlobRestProxy instance
container: 'container_name'
prefix: 'optional/path/prefix'
```

## AsyncAws S3

### Installation
Expand Down
10 changes: 8 additions & 2 deletions docs/B-configuration-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ flysystem:
client: 'aws_client_service'
bucket: 'bucket_name'
prefix: 'optional/path/prefix'

users2.storage:
adapter: 'custom_adapter'
adapter: 'azure'
options:
client: 'azure_client_service'
container: 'container_name'
prefix: 'optional/path/prefix'

users3.storage:
adapter: 'ftp'
Expand Down Expand Up @@ -72,4 +76,6 @@ flysystem:
options:
source: 'flysystem_storage_service_to_use'

users10.storage:
adapter: 'custom_adapter'
```
1 change: 1 addition & 0 deletions src/Adapter/AdapterDefinitionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public function __construct()
$this->builders = [
new Builder\AsyncAwsAdapterDefinitionBuilder(),
new Builder\AwsAdapterDefinitionBuilder(),
new Builder\AzureAdapterDefinitionBuilder(),
new Builder\FtpAdapterDefinitionBuilder(),
new Builder\GcloudAdapterDefinitionBuilder(),
new Builder\LocalAdapterDefinitionBuilder(),
Expand Down
57 changes: 57 additions & 0 deletions src/Adapter/Builder/AzureAdapterDefinitionBuilder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

/*
* This file is part of the flysystem-bundle project.
*
* (c) Titouan Galopin <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace League\FlysystemBundle\Adapter\Builder;

use League\Flysystem\AzureBlobStorage\AzureBlobStorageAdapter;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\OptionsResolver\OptionsResolver;

/**
* @author Titouan Galopin <[email protected]>
*
* @internal
*/
class AzureAdapterDefinitionBuilder extends AbstractAdapterDefinitionBuilder
{
public function getName(): string
{
return 'azure';
}

protected function getRequiredPackages(): array
{
return [
AzureBlobStorageAdapter::class => 'league/flysystem-azure-blob-storage',
];
}

protected function configureOptions(OptionsResolver $resolver)
{
$resolver->setRequired('client');
$resolver->setAllowedTypes('client', 'string');

$resolver->setRequired('container');
$resolver->setAllowedTypes('container', 'string');

$resolver->setDefault('prefix', '');
$resolver->setAllowedTypes('prefix', 'string');
}

protected function configureDefinition(Definition $definition, array $options)
{
$definition->setClass(AzureBlobStorageAdapter::class);
$definition->setArgument(0, new Reference($options['client']));
$definition->setArgument(1, $options['container']);
$definition->setArgument(2, $options['prefix']);
}
}
62 changes: 62 additions & 0 deletions tests/Adapter/Builder/AzureAdapterDefinitionBuilderTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

/*
* This file is part of the flysystem-bundle project.
*
* (c) Titouan Galopin <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Tests\League\FlysystemBundle\Adapter\Builder;

use League\Flysystem\AzureBlobStorage\AzureBlobStorageAdapter;
use League\FlysystemBundle\Adapter\Builder\AzureAdapterDefinitionBuilder;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\Reference;

class AzureAdapterDefinitionBuilderTest extends TestCase
{
public function createBuilder()
{
return new AzureAdapterDefinitionBuilder();
}

public function provideValidOptions()
{
yield 'minimal' => [[
'client' => 'my_client',
'container' => 'container_name',
]];

yield 'prefix' => [[
'client' => 'my_client',
'container' => 'container_name',
'prefix' => 'prefix/path',
]];
}

/**
* @dataProvider provideValidOptions
*/
public function testCreateDefinition($options)
{
$this->assertSame(AzureBlobStorageAdapter::class, $this->createBuilder()->createDefinition($options)->getClass());
}

public function testOptionsBehavior()
{
$definition = $this->createBuilder()->createDefinition([
'client' => 'my_client',
'container' => 'container_name',
'prefix' => 'prefix/path',
]);

$this->assertSame(AzureBlobStorageAdapter::class, $definition->getClass());
$this->assertInstanceOf(Reference::class, $definition->getArgument(0));
$this->assertSame('my_client', (string) $definition->getArgument(0));
$this->assertSame('container_name', $definition->getArgument(1));
$this->assertSame('prefix/path', $definition->getArgument(2));
}
}
7 changes: 7 additions & 0 deletions tests/Adapter/options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ fs_aws:
bucket: 'bucket_name'
prefix: 'optional/path/prefix'

fs_azure:
adapter: 'azure'
options:
client: 'azure_client_service'
container: 'container_name'
prefix: 'optional/path/prefix'

fs_ftp:
adapter: 'ftp'
options:
Expand Down
Loading