feat: add Azure OSS adapter#181
Conversation
818c9a7 to
1425a52
Compare
|
Should I find a way to tell PHPUnit to ignore the test if running with PHP < 8.1? |
|
Actually, since the issue arises from |
Removed azure-oss/storage-blob-flysystem from composer.json when testing with PHP 8.0 due to compatibility issues.
|
I found a working workaround: removing the dependency from the composer.json when using PHP 8.0. Let me know if you can think of a better solution... |
|
Wow, thank you very much @jonag |
|
Hi! Shouldn't we deprecate the use of the old adapter? This is the second external adapter (BunnyCDN), I think we shloud consider allowing the registration of a custom adapter in the bundle configuration, a bit like Symfony's security component for firewalls. I'm a bit busy at the moment, but I'd like to explore this possibility before merging them, to avoid any back-and-forth or introducing a BC break. |
|
Yes I think the old adapter should be deprecated since the "official" blob storage adapter is now abandonned. Regarding your other comment, if I understand correctly, it means that each custom adapter should create its own bundle that will add its configuration to this bundle? Something like this for example? |
|
@jonag Yes exactly. Or another solution if it is better to extend this list: https://github.com/thephpleague/flysystem-bundle/blob/3.x/src/Adapter/AdapterDefinitionFactory.php#L31-L43 |
This PR implements a solution to the issue discussed in thephpleague#181, enabling external bundles to register their custom storage adapters with Flysystem Bundle without requiring them to be directly added to the main bundle's codebase. I had to remove the `@internal` annotation from `AdapterDefinitionBuilderInterface` and `AbstractAdapterDefinitionBuilder` to allow them to be referenced by other bundles. ## Usage Example External bundles can now register their adapters as follows: ``` php class AzureBlobStorageAdapterBundle extends Bundle { /** * {@inheritdoc} */ public function build(ContainerBuilder $container): void { parent::build($container); /** @var FlysystemExtension $extension */ $extension = $container->getExtension('flysystem'); $extension->addAdapterDefinitionBuilder(new AzureOssAdapterDefinitionBuilder()); } } ```
|
What is the status of the PR? I would love to see it merged so we can start using the new Azure adapter. |
|
I would like to see this approche instead #182 |
|
any updates on getting this merged? |
|
Please read my previous message and #186 |
This PR implements a solution to the issue discussed in thephpleague#181, enabling external bundles to register their custom storage adapters with Flysystem Bundle without requiring them to be directly added to the main bundle's codebase. I had to remove the `@internal` annotation from `AdapterDefinitionBuilderInterface` and `AbstractAdapterDefinitionBuilder` to allow them to be referenced by other bundles. ## Usage Example External bundles can now register their adapters as follows: ``` php class AzureBlobStorageAdapterBundle extends Bundle { /** * {@inheritdoc} */ public function build(ContainerBuilder $container): void { parent::build($container); /** @var FlysystemExtension $extension */ $extension = $container->getExtension('flysystem'); $extension->addAdapterDefinitionBuilder(new AzureOssAdapterDefinitionBuilder()); } } ```
|
Any updates here? Given the old adapter is deprecated, would be great to use this new Azure library in a Symfony application. |
This PR implements a solution to the issue discussed in thephpleague#181, enabling external bundles to register their custom storage adapters with Flysystem Bundle without requiring them to be directly added to the main bundle's codebase. I had to remove the `@internal` annotation from `AdapterDefinitionBuilderInterface` and `AbstractAdapterDefinitionBuilder` to allow them to be referenced by other bundles. ## Usage Example External bundles can now register their adapters as follows: ``` php class AzureBlobStorageAdapterBundle extends Bundle { /** * {@inheritdoc} */ public function build(ContainerBuilder $container): void { parent::build($container); /** @var FlysystemExtension $extension */ $extension = $container->getExtension('flysystem'); $extension->addAdapterDefinitionBuilder(new AzureOssAdapterDefinitionBuilder()); } } ```
This PR implements a solution to the issue discussed in thephpleague#181, enabling external bundles to register their custom storage adapters with Flysystem Bundle without requiring them to be directly added to the main bundle's codebase. I had to remove the `@internal` annotation from `AdapterDefinitionBuilderInterface` and `AbstractAdapterDefinitionBuilder` to allow them to be referenced by other bundles. ## Usage Example External bundles can now register their adapters as follows: ``` php class AzureBlobStorageAdapterBundle extends Bundle { /** * {@inheritdoc} */ public function build(ContainerBuilder $container): void { parent::build($container); /** @var FlysystemExtension $extension */ $extension = $container->getExtension('flysystem'); $extension->addAdapterDefinitionBuilder(new AzureOssAdapterDefinitionBuilder()); } } ```
This PR implements a solution to the issue discussed in thephpleague#181, enabling external bundles to register their custom storage adapters with Flysystem Bundle without requiring them to be directly added to the main bundle's codebase. I had to remove the `@internal` annotation from `AdapterDefinitionBuilderInterface` and `AbstractAdapterDefinitionBuilder` to allow them to be referenced by other bundles. External bundles can now register their adapters as follows: ``` php class AzureBlobStorageAdapterBundle extends Bundle { /** * {@inheritdoc} */ public function build(ContainerBuilder $container): void { parent::build($container); /** @var FlysystemExtension $extension */ $extension = $container->getExtension('flysystem'); $extension->addAdapterDefinitionBuilder(new AzureOssAdapterDefinitionBuilder()); } } ```
This PR implements a solution to the issue discussed in thephpleague#181, enabling external bundles to register their custom storage adapters with Flysystem Bundle without requiring them to be directly added to the main bundle's codebase. I had to remove the `@internal` annotation from `AdapterDefinitionBuilderInterface` and `AbstractAdapterDefinitionBuilder` to allow them to be referenced by other bundles. External bundles can now register their adapters as follows: ``` php class AzureBlobStorageAdapterBundle extends Bundle { /** * {@inheritdoc} */ public function build(ContainerBuilder $container): void { parent::build($container); /** @var FlysystemExtension $extension */ $extension = $container->getExtension('flysystem'); $extension->addAdapterDefinitionBuilder(new AzureOssAdapterDefinitionBuilder()); } } ```
This PR implements a solution to the issue discussed in #181, enabling external bundles to register their custom storage adapters with Flysystem Bundle without requiring them to be directly added to the main bundle's codebase. I had to remove the `@internal` annotation from `AdapterDefinitionBuilderInterface` and `AbstractAdapterDefinitionBuilder` to allow them to be referenced by other bundles. External bundles can now register their adapters as follows: ``` php class AzureBlobStorageAdapterBundle extends Bundle { /** * {@inheritdoc} */ public function build(ContainerBuilder $container): void { parent::build($container); /** @var FlysystemExtension $extension */ $extension = $container->getExtension('flysystem'); $extension->addAdapterDefinitionBuilder(new AzureOssAdapterDefinitionBuilder()); } } ```
|
I just released this PR: #186 |
|
Heads up: I've taken a stab at the package-side implementation @maxhelias hinted at in the comment above, using the Lives in a new If/when that lands and tags a release, this PR can be closed in favour of the package-side implementation — Symfony users would install Posting in case it's useful context for closing the loop on this thread. |
…em adapter Introduces a new sub-package `azure-oss/storage-blob-flysystem-symfony` that registers an `azure_oss` adapter shortcut with `league/flysystem-bundle` 3.7+'s pluggable `AdapterDefinitionBuilderInterface` (thephpleague/flysystem-bundle#186). This is the canonical extension point: per-adapter builders now live in the adapter package rather than being merged into flysystem-bundle's core builder list. The author of PR thephpleague/flysystem-bundle#181 ("feat: add Azure OSS adapter") was pointed at #186 as the recommended approach; this package implements that. New sub-package: src/BlobFlysystemSymfony/ - AzureOssAdapterDefinitionBuilder: maps the `azure_oss` config key to a BlobContainerClient (built via a user-supplied BlobServiceClient service id) and the AzureBlobStorageAdapter. - AzureOssFlysystemBundle: extends Symfony's Bundle and registers the builder on flysystem-bundle's FlysystemExtension during build(), mirroring how FlysystemBundle wires its own built-in adapters. - composer.json declares `type: symfony-bundle` so Symfony Flex auto-registers the bundle for users who have flex installed. Configuration shape (see src/BlobFlysystemSymfony/README.md for the full reference): flysystem: storages: default.storage: azure_oss: client: azure_blob_service_client container: '%env(AZURE_STORAGE_CONTAINER)%' # optional: prefix, mime_type_detector, # visibility_handling (throw|ignore), public_container Tests under tests/BlobFlysystemSymfony/: - AzureOssAdapterDefinitionBuilderTest extends flysystem-bundle's AbstractAdapterDefinitionBuilderTest (the same base used by the bundle's built-in builders), driving minimal and full option fixtures through the Config tree and asserting on the resulting Definition objects. Adds extra coverage for getName(), getRequiredPackages(), and the null-mime-type-detector path. - AzureOssFlysystemBundleTest boots a ContainerBuilder, runs both FlysystemBundle::build() and AzureOssFlysystemBundle::build() in the same order Symfony's Kernel would, and asserts that the azure_oss builder is registered on the FlysystemExtension. Root composer.json gains four require-dev entries needed by the new package's CI path: `league/flysystem-bundle`, `symfony/config`, `symfony/dependency-injection`, `symfony/http-kernel`. No other config changes — autoload PSR-4 `AzureOss\\Storage\\` -> `src/` already covers the new directory; phpunit.xml's `tests/` glob picks up the new test suite; phpstan and pint configs apply unchanged. The new package follows the existing conventions: - final class with @internal PHPDoc, declare(strict_types=1) - pint Laravel preset with declare_strict_types + final_internal_class - PHPStan level 10 + strict-rules clean (no asserts/@var/ignores) Verification: - vendor/bin/phpstan analyse --memory-limit=2G : OK - vendor/bin/phpunit --filter 'BlobFlysystemSymfony' : 8 tests / 32 assertions, all green - vendor/bin/pint src tests --test : PASS (146 files) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Hello,
Here is my attempt to add support for
azure-oss/storage-blob-flysystemto the bundle (#178).I am not sure about the name I chose to identify the adapter (azureoss), maybe you have a better suggestion?
Jonag