Skip to content

Commit

Permalink
Add Azure Blob Storage adapter (#271)
Browse files Browse the repository at this point in the history
Co-authored-by: MD Nurullah <[email protected]>
Co-authored-by: David Greminger <[email protected]>
  • Loading branch information
3 people authored Dec 1, 2022
1 parent 36449c1 commit 33bb123
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 9 deletions.
10 changes: 3 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/[email protected]
with:
php-version: 7.4
php-version: 8.0
extensions: dom, fileinfo, filter, gd, hash, intl, json, mbstring, pcre, pdo, zlib
coverage: none

Expand All @@ -36,12 +36,8 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [7.4, 8.0, 8.1]
php: [8.0, 8.1]
symfony: [4.4, 5.4, 6.0]
exclude:
# Symfony 6.0 does not supports php <8.0
- php: 7.4
symfony: 6.0
steps:
- name: Setup PHP
uses: shivammathur/[email protected]
Expand All @@ -67,7 +63,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/[email protected]
with:
php-version: 7.4
php-version: 8.0
extensions: dom, fileinfo, filter, gd, hash, intl, json, mbstring, pcre, pdo_mysql, zlib
coverage: none

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The OneupFlysystemBundle provides a [Flysystem](https://github.com/thephpleague/
* [Google Cloud Storage](https://cloud.google.com/storage)
* [AsyncAwsS3](https://async-aws.com/)
* [AwsS3](http://aws.amazon.com/de/sdkforphp/)
* [AzureBlobStorage](https://azure.microsoft.com/en-us/services/storage/blobs/)
* [Ftp](http://php.net/manual/en/book.ftp.php)
* [Local filesystem](http://php.net/manual/en/ref.filesystem.php)
* [Sftp](http://phpseclib.sourceforge.net/sftp/intro.html)
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
}
],
"require": {
"php": "^7.4 || ^8.0",
"php": "^8.0",
"league/flysystem": "^2.0 || ^3.0",
"symfony/config": "^4.4 || ^5.3 || ^6.0",
"symfony/dependency-injection": "^4.4 || ^5.3 || ^6.0",
Expand All @@ -40,6 +40,7 @@
"league/flysystem-google-cloud-storage": "^2.0 || ^3.0",
"league/flysystem-memory": "^2.0 || ^3.0",
"league/flysystem-sftp": "^2.0 || ^3.0",
"league/flysystem-azure-blob-storage": "^3.0",
"phpstan/phpstan": "^1.4",
"phpunit/phpunit": "^9.5",
"royvoetman/flysystem-gitlab-storage": "^2.0 || ^3.0",
Expand Down
20 changes: 20 additions & 0 deletions doc/adapter_azure_blob_storage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Use the Azure Blob Storage adapter

This adapter connects to the filesystem in the Azure Blob Storage.


```yml
oneup_flysystem:
adapters:
acme.flysystem_adapter:
azureblob:
client: 'azure_blob_storage_client' # Service ID of the MicrosoftAzure\Storage\Blob\BlobRestProxy
container: 'container-name'
prefix: 'optional/prefix'
```
For more details on the other parameters, take a look at the [Flysystem documentation](https://flysystem.thephpleague.com/docs/adapter/azure-blob-storage/).
## More to know
* [Create and use your filesystem](filesystem_create.md)
2 changes: 2 additions & 0 deletions doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Composer will now fetch and install this bundle in the vendor directory `vendor/
* The InMemory adapter requires `"league/flysystem-memory"`
* The AsyncAwsS3 adapter requires `"league/flysystem-async-aws-s3"`
* The Gitlab adapter requires `"royvoetman/flysystem-gitlab-storage"`
* The Azure Blob Storage adapter requires `"league/flysystem-azure-blob-storage"`

### Step 2: Enable the bundle
Enable the bundle in the kernel:
Expand Down Expand Up @@ -78,6 +79,7 @@ There are a bunch of adapters for you to use:
* [InMemoryAdapter](adapter_in_memory.md)
* [Sftp](adapter_sftp.md)
* [Gitlab](adapter_gitlab.md)
* [AzureBlobStorage](adapter_azure_blob_storage.md)
* [Custom](adapter_custom.md)
### Step 4: Next steps
Expand Down
40 changes: 40 additions & 0 deletions src/DependencyInjection/Factory/Adapter/AzureBlobFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

declare(strict_types=1);

namespace Oneup\FlysystemBundle\DependencyInjection\Factory\Adapter;

use Oneup\FlysystemBundle\DependencyInjection\Factory\AdapterFactoryInterface;
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;

class AzureBlobFactory implements AdapterFactoryInterface
{
public function getKey(): string
{
return 'azureblob';
}

public function create(ContainerBuilder $container, string $id, array $config): void
{
$container
->setDefinition($id, new ChildDefinition('oneup_flysystem.adapter.azureblob'))
->replaceArgument(0, new Reference($config['client']))
->replaceArgument(1, $config['container'])
->replaceArgument(2, $config['prefix'])
;
}

public function addConfiguration(NodeDefinition $node): void
{
$node
->children()
->scalarNode('client')->isRequired()->end()
->scalarNode('container')->isRequired()->end()
->scalarNode('prefix')->defaultNull()->end()
->end()
;
}
}
2 changes: 1 addition & 1 deletion src/DependencyInjection/Factory/Adapter/LocalFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function create(ContainerBuilder $container, string $id, array $config):
if (isset($config['permissions']) && null !== $config['permissions']) {
$visibilityConverter = new Definition(PortableVisibilityConverter::class);
$visibilityConverter->setFactory([PortableVisibilityConverter::class, 'fromArray']);
$visibilityConverter->setArgument(0, $config['permissions'] ?? []);
$visibilityConverter->setArgument(0, $config['permissions']);
}

$container
Expand Down
5 changes: 5 additions & 0 deletions src/Resources/config/adapters.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,10 @@
<argument/><!-- Client -->
<argument/><!-- Prefix -->
</service>
<service id="oneup_flysystem.adapter.azureblob" class="League\Flysystem\AzureBlobStorage\AzureBlobStorageAdapter" abstract="true" public="false">
<argument /><!-- Client -->
<argument /><!-- Container -->
<argument /><!-- Prefix -->
</service>
</services>
</container>
4 changes: 4 additions & 0 deletions src/Resources/config/factories.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,9 @@
class="Oneup\FlysystemBundle\DependencyInjection\Factory\Adapter\GitlabFactory">
<tag name="oneup_flysystem.adapter_factory"/>
</service>
<service id="oneup_flysystem.adapter_factory.azureblob"
class="Oneup\FlysystemBundle\DependencyInjection\Factory\Adapter\AzureBlobFactory">
<tag name="oneup_flysystem.adapter_factory"/>
</service>
</services>
</container>

0 comments on commit 33bb123

Please sign in to comment.