### Install Vendors Source: https://github.com/1up-lab/oneupflysystembundle/blob/main/doc/tests.md Install all project dependencies using Composer. This command is typically run after cloning the repository. ```sh composer install --dev ``` -------------------------------- ### Install OneupFlysystemBundle with Composer Source: https://github.com/1up-lab/oneupflysystembundle/blob/main/doc/index.md Use Composer to download and install the bundle into your Symfony project. ```sh composer require oneup/flysystem-bundle ``` -------------------------------- ### Custom Adapter Implementation Source: https://context7.com/1up-lab/oneupflysystembundle/llms.txt An example implementation of the `FilesystemAdapter` interface for a custom storage backend. This class must provide logic for all required methods. ```php use League\Flysystem\FilesystemAdapter; use League\Flysystem\Config; use League\Flysystem\FileAttributes; class MyCustomAdapter implements FilesystemAdapter { public function write(string $path, string $contents, Config $config): void { // Custom write logic } public function read(string $path): string { // Custom read logic return ''; } // Implement remaining FilesystemAdapter methods... public function fileExists(string $path): bool { return false; } public function directoryExists(string $path): bool { return false; } public function writeStream(string $path, $contents, Config $config): void {} public function readStream(string $path) { return null; } public function delete(string $path): void {} public function deleteDirectory(string $path): void {} public function createDirectory(string $path, Config $config): void {} public function setVisibility(string $path, string $visibility): void {} public function visibility(string $path): FileAttributes { return new FileAttributes($path); } public function mimeType(string $path): FileAttributes { return new FileAttributes($path); } public function lastModified(string $path): FileAttributes { return new FileAttributes($path); } public function fileSize(string $path): FileAttributes { return new FileAttributes($path); } public function listContents(string $path, bool $deep): iterable { return []; } public function move(string $source, string $destination, Config $config): void {} public function copy(string $source, string $destination, Config $config): void {} } ``` -------------------------------- ### SFTP Service Example Source: https://context7.com/1up-lab/oneupflysystembundle/llms.txt A service class that injects the SFTP filesystem operator for file operations. This example demonstrates writing a file to the configured SFTP storage. ```php use League\Flysystem\FilesystemOperator; class SftpService { public function __construct(private FilesystemOperator $sftpFilesystem) {} public function syncFile(string $path, string $content): void { $this->sftpFilesystem->write($path, $content); } } ``` -------------------------------- ### GitLab Storage Service Example Source: https://context7.com/1up-lab/oneupflysystembundle/llms.txt A service class utilizing the GitLab filesystem operator. This example shows how to write content to a file within the GitLab repository. ```php use League\Flysystem\FilesystemOperator; class GitlabStorageService { public function __construct(private FilesystemOperator $gitlabFilesystem) {} public function commitFile(string $path, string $content): void { $this->gitlabFilesystem->write($path, $content); } } ``` -------------------------------- ### In-Memory Storage Service Example Source: https://context7.com/1up-lab/oneupflysystembundle/llms.txt A service demonstrating the use of the in-memory filesystem. It writes content, reads it back, processes it, and then deletes the temporary file. ```php use League\Flysystem\FilesystemOperator; class TempStorageService { public function __construct(private FilesystemOperator $tempFilesystem) {} public function processTemporarily(string $content): string { $this->tempFilesystem->write('temp.txt', $content); $processed = strtoupper($this->tempFilesystem->read('temp.txt')); $this->tempFilesystem->delete('temp.txt'); return $processed; } } ``` -------------------------------- ### Running Bundle Tests Source: https://context7.com/1up-lab/oneupflysystembundle/llms.txt Provides commands for cloning the repository, installing dependencies, and running tests using PHPUnit, PHPStan for static analysis, and php-cs-fixer for code style. ```sh # Clone and install git clone git://github.com/1up-lab/OneupFlysystemBundle.git cd OneupFlysystemBundle composer install --dev # Run unit tests vendor/bin/phpunit # Run static analysis (max level) vendor/bin/phpstan analyze src/ tests/ --level=max # Run code style fixer vendor/bin/php-cs-fixer fix ``` -------------------------------- ### Use Local Filesystem in Service Source: https://context7.com/1up-lab/oneupflysystembundle/llms.txt Inject the configured filesystem service into your PHP class to perform file operations. The example shows writing and reading files. ```php use League\Flysystem\FilesystemOperator; class UploadService { public function __construct(private FilesystemOperator $uploadsFilesystem) {} public function store(string $filename, string $content): void { $this->uploadsFilesystem->write($filename, $content); // File written to %kernel.project_dir%/var/uploads/ } public function read(string $filename): string { return $this->uploadsFilesystem->read($filename); } } ``` -------------------------------- ### Use FTP Filesystem in PHP Source: https://context7.com/1up-lab/oneupflysystembundle/llms.txt Example of injecting and using the configured FTP filesystem operator in a PHP service for uploading and checking file existence. ```php use League lysystem ilesystemOperator; class FtpService { public function __construct(private FilesystemOperator $ftpFilesystem) {} public function uploadFile(string $remotePath, string $content): void { $this->ftpFilesystem->write($remotePath, $content); } public function fileExists(string $path): bool { return $this->ftpFilesystem->fileExists($path); } } ``` -------------------------------- ### Configure Filesystem with YAML Alias Source: https://context7.com/1up-lab/oneupflysystembundle/llms.txt Defines a local filesystem adapter and a 'media' filesystem with an optional alias for autowiring. This configuration is suitable for local development or simple setups. ```yaml # config/packages/oneup_flysystem.yaml oneup_flysystem: adapters: local_adapter: local: location: "%kernel.project_dir%/var/uploads" filesystems: media: adapter: local_adapter alias: App\Storage\MediaFilesystem # Optional alias for autowiring ``` -------------------------------- ### Use Async AWS S3 Filesystem in PHP Source: https://context7.com/1up-lab/oneupflysystembundle/llms.txt Example of injecting and using the configured async AWS S3 filesystem operator in a PHP service. ```php use League lysystem ilesystemOperator; class ImageService { public function __construct(private FilesystemOperator $imagesFilesystem) {} public function save(string $name, string $data): void { $this->imagesFilesystem->write($name, $data); } } ``` -------------------------------- ### Use Google Cloud Storage Filesystem in PHP Source: https://context7.com/1up-lab/oneupflysystembundle/llms.txt Example of injecting and using the configured Google Cloud Storage filesystem operator in a PHP service for uploading and deleting files. ```php use League lysystem ilesystemOperator; class GcsService { public function __construct(private FilesystemOperator $gcsFilesystem) {} public function upload(string $path, string $content): void { $this->gcsFilesystem->write($path, $content); } public function delete(string $path): void { $this->gcsFilesystem->delete($path); } } ``` -------------------------------- ### Use Azure Blob Storage Filesystem in PHP Source: https://context7.com/1up-lab/oneupflysystembundle/llms.txt Example of injecting and using the configured Azure Blob Storage filesystem operator in a PHP service for writing files. ```php use League lysystem ilesystemOperator; class AzureStorageService { public function __construct(private FilesystemOperator $azureFilesystem) {} public function writeFile(string $path, string $content): void { $this->azureFilesystem->write($path, $content); } } ``` -------------------------------- ### Use AWS S3 v3 Storage in Service Source: https://context7.com/1up-lab/oneupflysystembundle/llms.txt Inject the S3 filesystem service into your PHP class for cloud storage operations. The example demonstrates uploading and listing files. ```php use League\Flysystem\FilesystemOperator; class S3StorageService { public function __construct(private FilesystemOperator $cloudStorageFilesystem) {} public function upload(string $path, string $contents): void { $this->cloudStorageFilesystem->write($path, $contents); // Stored at s3://my-app-bucket/uploads/ } public function listFiles(string $directory): iterable { return $this->cloudStorageFilesystem->listContents($directory, true); } } ``` -------------------------------- ### Configure Local Adapter Source: https://github.com/1up-lab/oneupflysystembundle/blob/main/doc/adapter_local.md Use this configuration to set up the local adapter, specifying the directory for file storage. The `location` parameter is mandatory. ```yaml oneup_flysystem: adapters: my_adapter: local: location: "%kernel.root_dir%/../uploads" lazy: ~ # boolean (default "false") writeFlags: ~ linkHandling: ~ permissions: file: public: 0o644 private: 0o600 dir: public: 0o755 private: 0o700 lazyRootCreation: ~ # boolean (default "false") ``` -------------------------------- ### Configure OneupFlysystemBundle with PHP Source: https://github.com/1up-lab/oneupflysystembundle/blob/main/doc/filesystem_php_config.md Use this PHP configuration file to set up adapters and filesystems for the OneupFlysystemBundle. This method is suitable for Symfony 5 projects. ```php extension('oneup_flysystem', [ 'adapters' => [ 'my_adapter' => [ 'local' => [ 'directory' => '%kernel.root_dir%/cache' ] ] ], 'filesystems' => [ 'my_filesystem' => [ 'adapter' => 'my_adapter', 'visibility' => 'private' 'directory_visibility' => 'private' ] ] ]); }; ``` -------------------------------- ### Configure In-Memory Adapter Source: https://context7.com/1up-lab/oneupflysystembundle/llms.txt Sets up an in-memory adapter for temporary file storage. This is useful for testing or operations where persistence is not required. Requires `league/flysystem-memory`. ```yaml # config/packages/oneup_flysystem.yaml (or test config) oneup_flysystem: adapters: memory_adapter: memory: ~ filesystems: temp: adapter: memory_adapter ``` -------------------------------- ### Configure Local Filesystem Adapter Source: https://context7.com/1up-lab/oneupflysystembundle/llms.txt Configure a local filesystem adapter in config/packages/oneup_flysystem.yaml. This adapter stores files on the same server as the application and allows for fine-grained permission configuration. ```yaml # config/packages/oneup_flysystem.yaml oneup_flysystem: adapters: my_local_adapter: local: location: "%kernel.project_dir%/var/uploads" lazy: false lazyRootCreation: false permissions: file: public: 0o644 private: 0o600 dir: public: 0o755 private: 0o700 filesystems: uploads: adapter: my_local_adapter visibility: public directory_visibility: public ``` -------------------------------- ### Configure a Filesystem Source: https://github.com/1up-lab/oneupflysystembundle/blob/main/doc/filesystem_create.md Configure a filesystem by specifying an adapter. This exposes a service for retrieval. ```yaml oneup_flysystem: adapter: ~ filesystems: acme: adapter: my_adapter alias: ~ mount: ~ visibility: ~ directory_visibility: ~ ``` -------------------------------- ### Configure Filesystems with PHP Source: https://context7.com/1up-lab/oneupflysystembundle/llms.txt Configures multiple adapters (local and S3) and filesystems ('local_storage', 'cloud_storage') using PHP for Symfony 5+ config loading. This approach allows for dynamic configuration and better integration with PHP-based services. ```php extension('oneup_flysystem', [ 'adapters' => [ 'local_adapter' => [ 'local' => [ 'location' => '%kernel.project_dir%/var/storage', ] ], 's3_adapter' => [ 'awss3v3' => [ 'client' => 'acme.s3_client', 'bucket' => 'my-bucket', 'prefix' => 'uploads', ] ], ], 'filesystems' => [ 'local_storage' => [ 'adapter' => 'local_adapter', 'visibility' => 'private', 'directory_visibility' => 'private', ], 'cloud_storage' => [ 'adapter' => 's3_adapter', 'visibility' => 'public', ], ], ]); }; ``` -------------------------------- ### Run PHPUnit Tests Source: https://github.com/1up-lab/oneupflysystembundle/blob/main/doc/tests.md Execute the unit tests for the bundle using PHPUnit. Ensure you are in the project's root directory. ```sh vendor/bin/phpunit ``` -------------------------------- ### Configure SFTP Adapter Source: https://github.com/1up-lab/oneupflysystembundle/blob/main/doc/adapter_sftp.md Provide at least the host, username, and root path for the SFTP adapter. Refer to Flysystem documentation for additional parameters. ```yaml oneup_flysystem: adapters: my_adapter: sftp: options: host: 'ftp.domain.com' username: 'foo' root: '/upload' ``` -------------------------------- ### Configure Gitlab Adapter Source: https://github.com/1up-lab/oneupflysystembundle/blob/main/doc/adapter_gitlab.md Set the previously defined Gitlab client service as the value for the `client` key in the `oneup_flysystem` configuration. An optional `prefix` can also be specified. ```yaml oneup_flysystem: adapters: acme.gitlab_adapter: gitlab: client: acme.gitlab_client prefix: 'optional/path/prefix' ``` -------------------------------- ### Configure GitLab Client Service Source: https://context7.com/1up-lab/oneupflysystembundle/llms.txt Sets up the GitLab client service required for the GitLab adapter. Project ID, branch, base URL, and access token should be configured. ```yaml # config/services.yaml services: acme.gitlab_client: class: RoyVoetman\FlysystemGitlab\Client arguments: - '%env(GITLAB_PROJECT_ID)%' # Project ID - 'main' # Branch - 'https://gitlab.com' # Base URL - '%env(GITLAB_ACCESS_TOKEN)%' # Personal access token ``` -------------------------------- ### Clone the Bundle Source: https://github.com/1up-lab/oneupflysystembundle/blob/main/doc/tests.md Clone the OneupFlysystemBundle repository to your local machine. ```sh git clone git://github.com/1up-lab/OneupFlysystemBundle.git ``` -------------------------------- ### Retrieve Filesystem by Alias Source: https://github.com/1up-lab/oneupflysystembundle/blob/main/doc/filesystem_create.md Retrieve the filesystem service using the custom alias defined in the configuration. ```php $filesystem = $container->get('acme_filesystem'); ``` -------------------------------- ### Configure Google Cloud Storage Adapter Source: https://github.com/1up-lab/oneupflysystembundle/blob/main/doc/adapter_google_cloud_storage.md Configure the Google Cloud Storage adapter in your application's configuration. Ensure the `google_cloud_storage_client` service is correctly set up. ```yaml oneup_flysystem: adapters: acme.flysystem_adapter: googlecloudstorage: client: 'google_cloud_storage_client' # Service ID of the Google\Cloud\Storage\StorageClient bucket: 'my_gcs_bucket' prefix: '' ``` -------------------------------- ### Configure SFTP Adapter Source: https://context7.com/1up-lab/oneupflysystembundle/llms.txt Defines an SFTP adapter in the bundle configuration. Ensure SFTP connection details are provided via environment variables. ```yaml oneup_flysystem: adapters: sftp_adapter: sftp: options: host: '%env(SFTP_HOST)%' username: '%env(SFTP_USER)%' password: '%env(SFTP_PASS)%' root: '/home/user/uploads' port: 22 timeout: 30 filesystems: sftp: adapter: sftp_adapter ``` -------------------------------- ### Configure SFTP Adapter Source: https://context7.com/1up-lab/oneupflysystembundle/llms.txt Configuration for the SFTP adapter. Requires `host`, `username`, and `root`. Additional options for authentication and connection can be provided. ```yaml oneup_flysystem: adapters: sftp_adapter: sftp: host: '%env(SFTP_HOST)%' username: '%env(SFTP_USER)%' root: '/path/to/root' password: '%env(SFTP_PASSWORD)%' port: 22 privateKey: '/path/to/private/key' passphrase: '%env(SFTP_PRIVATE_KEY_PASSPHRASE)%' timeout: 10 filesystems: sftp: adapter: sftp_adapter ``` -------------------------------- ### Configure AsyncAwsS3 Adapter in Flysystem Source: https://github.com/1up-lab/oneupflysystembundle/blob/main/doc/adapter_async_aws_s3.md Integrate the created S3 client service into the oneup_flysystem configuration. Specify the bucket name and optionally a prefix and visibility converter. ```yml oneup_flysystem: adapters: acme.flysystem_adapter: async_aws_s3: client: acme.async_s3_client bucket: 'my_image_bucket' prefix: '' visibilityConverter: acme.async.portable_visibility_converter ``` -------------------------------- ### Inject Filesystem in Services Source: https://github.com/1up-lab/oneupflysystembundle/blob/main/doc/filesystem_create.md Inject filesystems into your services using dependency injection. Reference the service name or its alias in the service arguments. ```yaml services: app.my_service: class: App\MyService arguments: - '@oneup_flysystem.acme_filesystem' # Inject the resolved service name, or the alias (see previous section) ``` -------------------------------- ### Configure Async AWS S3 Adapter Source: https://context7.com/1up-lab/oneupflysystembundle/llms.txt Configuration for an asynchronous AWS S3 adapter. Ensure the `acme.async_s3_client` service is properly defined. ```yaml oneup_flysystem: adapters: async_s3_adapter: async_aws_s3: client: acme.async_s3_client bucket: 'my_image_bucket' prefix: 'images' visibilityConverter: acme.async.portable_visibility_converter filesystems: images: adapter: async_s3_adapter ``` -------------------------------- ### Configure Local Filesystem Adapter and Filesystem Source: https://github.com/1up-lab/oneupflysystembundle/blob/main/doc/index.md Define a local adapter and a filesystem in your Symfony configuration. The adapter specifies the storage location, and the filesystem uses this adapter. Optional visibility settings for files and directories can also be configured. ```yaml # app/config/config.yml oneup_flysystem: adapters: my_adapter: local: location: "%kernel.root_dir%/cache" filesystems: my_filesystem: adapter: my_adapter # optional - defines the default visibility of files: `public` or `private` (default) visibility: private # optional - defines the default visibility of directories: `public` or `private` (default) directory_visibility: private ``` -------------------------------- ### Configure Google Cloud Storage Adapter Source: https://context7.com/1up-lab/oneupflysystembundle/llms.txt Configuration for the Google Cloud Storage adapter. The `client` should reference the service defined in `services.yaml`. ```yaml oneup_flysystem: adapters: gcs_adapter: googlecloudstorage: client: google_cloud_storage_client bucket: 'my_gcs_bucket' prefix: 'app/uploads' filesystems: gcs: adapter: gcs_adapter ``` -------------------------------- ### Configure FTP Adapter in YAML Source: https://github.com/1up-lab/oneupflysystembundle/blob/main/doc/adapter_ftp.md Provide FTP connection details and options in the app/config/config.yml file. The host, root, username, and password are required parameters for the FTP adapter. ```yaml oneup_flysystem: acme.ftp.portable_visibility_converter: class: League\Flysystem\UnixVisibility\PortableVisibilityConverter adapters: my_adapter: ftp: options: host: 'ftp.hostname.com' # required root: '/upload' # required username: 'username' # required password: 'password' # required visibilityConverter: acme.ftp.portable_visibility_converter ``` -------------------------------- ### Register Custom Adapter Service Source: https://context7.com/1up-lab/oneupflysystembundle/llms.txt Defines a custom adapter service in `services.yaml`. This allows integration with any storage backend by implementing `League\Flysystem\FilesystemAdapter`. ```yaml # config/services.yaml services: App\Storage\MyCustomAdapter: arguments: $endpoint: '%env(CUSTOM_STORAGE_ENDPOINT)%' ``` -------------------------------- ### Configure Custom Flysystem Adapter Source: https://github.com/1up-lab/oneupflysystembundle/blob/main/doc/adapter_custom.md Define a custom Flysystem adapter by specifying its service ID in the oneup_flysystem configuration. Ensure the service implements League\Flysystem\AdapterInterface. ```yaml oneup_flysystem: adapters: acme.flysystem_adapter: custom: service: my_flysystem_service ``` -------------------------------- ### Configure AwsS3v3 Adapter Source: https://github.com/1up-lab/oneupflysystembundle/blob/main/doc/adapter_awss3.md Configure the AwsS3v3 adapter in the oneup_flysystem configuration, referencing the previously defined S3 client service. The bucket and an optional prefix can be specified. ```yaml oneup_flysystem: adapters: acme.flysystem_adapter: awss3v3: client: acme.s3_client bucket: 'bucket-name' prefix: 'path/prefix' # Optional path prefix, you can set empty string visibilityConverter: acme.awss3v3.portable_visibility_converter ``` -------------------------------- ### Configure AWS S3 v3 Adapter Source: https://context7.com/1up-lab/oneupflysystembundle/llms.txt Configure an AWS S3 v3 adapter in config/packages/oneup_flysystem.yaml. This requires setting up an S3Client service and specifying bucket details. ```yaml # config/services.yaml services: acme.awss3v3.portable_visibility_converter: class: League\Flysystem\AwsS3V3\PortableVisibilityConverter acme.s3_client: class: Aws\S3\S3Client arguments: - version: 'latest' region: 'eu-central-1' credentials: key: '%env(AWS_KEY)%' secret: '%env(AWS_SECRET)%' # config/packages/oneup_flysystem.yaml oneup_flysystem: adapters: s3_adapter: awss3v3: client: acme.s3_client bucket: 'my-app-bucket' prefix: 'uploads' visibilityConverter: acme.awss3v3.portable_visibility_converter options: ACL: bucket-owner-full-control # useful for cross-account uploads filesystems: cloud_storage: adapter: s3_adapter visibility: public ``` -------------------------------- ### Configure FTP Adapter Source: https://context7.com/1up-lab/oneupflysystembundle/llms.txt Configuration for the FTP adapter. Requires `FTP_HOST`, `FTP_USER`, and `FTP_PASS` environment variables. Note `passive` and `ssl` options. ```yaml oneup_flysystem: adapters: ftp_adapter: ftp: options: host: '%env(FTP_HOST)%' root: '/var/www/uploads' username: '%env(FTP_USER)%' password: '%env(FTP_PASS)%' port: 21 passive: true ssl: false timeout: 30 visibilityConverter: acme.ftp.portable_visibility_converter filesystems: ftp: adapter: ftp_adapter ``` -------------------------------- ### Configure Memory Adapter Source: https://github.com/1up-lab/oneupflysystembundle/blob/main/doc/adapter_in_memory.md Configure the in-memory adapter in your application's configuration file. ```yaml oneup_flysystem: adapters: memory_adapter: memory: ~ ``` -------------------------------- ### Configure Google Cloud Storage Client Source: https://context7.com/1up-lab/oneupflysystembundle/llms.txt Defines the Google Cloud Storage client service. Ensure `GCS_PROJECT_ID` and `GCS_KEY_FILE` environment variables are set. ```yaml services: google_cloud_storage_client: class: Google arguments: - projectId: '%env(GCS_PROJECT_ID)%' keyFilePath: '%env(GCS_KEY_FILE)%' ``` -------------------------------- ### Configure Azure Blob Storage Adapter Source: https://context7.com/1up-lab/oneupflysystembundle/llms.txt Configuration for the Azure Blob Storage adapter. The `client` should reference the service defined in `services.yaml`. ```yaml oneup_flysystem: adapters: azure_adapter: azureblob: client: azure_blob_storage_client container: 'my-container' prefix: 'optional/prefix' filesystems: azure: adapter: azure_adapter ``` -------------------------------- ### Enable OneupFlysystemBundle in Symfony Source: https://context7.com/1up-lab/oneupflysystembundle/llms.txt Enable the bundle by adding its class to the config/bundles.php file. This makes the bundle's services available in your Symfony application. ```php // config/bundles.php return [ // ... Oneup\FlysystemBundle\OneupFlysystemBundle::class => ['all' => true], ]; ``` -------------------------------- ### Configure GitLab Adapter Source: https://context7.com/1up-lab/oneupflysystembundle/llms.txt Registers the GitLab adapter using the previously defined GitLab client service. A prefix can be specified for the storage root within the repository. ```yaml # config/packages/oneup_flysystem.yaml oneup_flysystem: adapters: gitlab_adapter: gitlab: client: acme.gitlab_client prefix: 'assets' filesystems: gitlab: adapter: gitlab_adapter ``` -------------------------------- ### Configure AwsS3v3 Adapter with ACL Option Source: https://github.com/1up-lab/oneupflysystembundle/blob/main/doc/adapter_awss3.md Use the 'options' key to pass additional parameters to the AWS SDK, such as setting the ACL to 'bucket-owner-full-control' to allow the bucket owner full control over an object. ```yaml oneup_flysystem: adapters: acme.flysystem_adapter: awss3v3: client: acme.s3_client bucket: 'bucket-name' prefix: 'path/prefix' # Optional path prefix, you can set empty string options: ACL: bucket-owner-full-control ``` -------------------------------- ### Retrieve Filesystem Service Source: https://github.com/1up-lab/oneupflysystembundle/blob/main/doc/filesystem_create.md Retrieve the configured filesystem service using its generated name. The service name follows the pattern `oneup_flysystem.%s_filesystem`. ```php $filesystem = $container->get('oneup_flysystem.acme_filesystem'); ``` -------------------------------- ### Access Filesystem via Dependency Injection Source: https://context7.com/1up-lab/oneupflysystembundle/llms.txt Demonstrates preferred method of injecting FilesystemOperator into a Symfony service using autowiring. The argument name must match the filesystem name suffixed with 'Filesystem'. ```php // Access via container (service locator pattern - not recommended) $filesystem = $container->get('oneup_flysystem.media_filesystem'); // Inject by service ID in services.yaml // config/services.yaml: // App\Service\MediaService: // arguments: // - '@oneup_flysystem.media_filesystem' // Preferred: autowire using the filesystem name as argument name // Symfony 4.2+ resolves FilesystemOperator $mediaFilesystem automatically use League\Flysystem\FilesystemOperator; class MediaService { // Argument name must match: {filesystemName}Filesystem public function __construct(private FilesystemOperator $mediaFilesystem) {} public function saveUpload(string $filename, string $data): void { $this->mediaFilesystem->write("uploads/{$filename}", $data); } public function getUrl(string $filename): string { // Check existence before reading if (!$this->mediaFilesystem->fileExists("uploads/{$filename}")) { throw new \RuntimeException("File not found: {$filename}"); } return $this->mediaFilesystem->read("uploads/{$filename}"); } } ``` -------------------------------- ### Configure AsyncAws S3 Client Source: https://github.com/1up-lab/oneupflysystembundle/blob/main/doc/adapter_async_aws_s3.md Define the S3 client service with necessary credentials and region. Refer to async-aws.com for more details on client instantiation. ```yml services: acme.async.portable_visibility_converter: class: League\Flysystem\AsyncAwsS3\PortableVisibilityConverter acme.async_s3_client: class: AsyncAws\S3\S3Client arguments: - region: 'eu-central-1' accessKeyId: 'AKIAIOSFODNN7EXAMPLE' accessKeySecret: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY' ``` -------------------------------- ### Run PHPStan Static Analysis Source: https://github.com/1up-lab/oneupflysystembundle/blob/main/doc/tests.md Perform static analysis on the source and test files using PHPStan to identify potential errors. Use the --level=max flag for the most thorough analysis. ```sh vendor/bin/phpstan analyze src/ tests/ --level=max ``` -------------------------------- ### Configure Custom Adapter Source: https://context7.com/1up-lab/oneupflysystembundle/llms.txt Registers a custom adapter in the bundle configuration, referencing the custom service defined in `services.yaml`. This enables the use of proprietary or third-party storage solutions. ```yaml # config/packages/oneup_flysystem.yaml oneup_flysystem: adapters: custom_adapter: custom: service: App\Storage\MyCustomAdapter filesystems: custom: adapter: custom_adapter ``` -------------------------------- ### Configure Azure Blob Storage Adapter Source: https://github.com/1up-lab/oneupflysystembundle/blob/main/doc/adapter_azure_blob_storage.md Use this YAML configuration to set up the Azure Blob Storage adapter. Specify the service ID for your Azure Blob Storage client, the container name, and an optional prefix for organizing files. ```yaml 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' ``` -------------------------------- ### Configure AsyncAws S3 Client Source: https://context7.com/1up-lab/oneupflysystembundle/llms.txt Configure an AsyncAws S3 client service in config/services.yaml. This is an alternative to the official AWS SDK, suitable for projects using the AsyncAws ecosystem. ```yaml # config/services.yaml services: acme.async.portable_visibility_converter: class: League\Flysystem\AsyncAwsS3\PortableVisibilityConverter acme.async_s3_client: class: AsyncAws\S3\S3Client arguments: - region: 'eu-central-1' accessKeyId: '%env(AWS_ACCESS_KEY_ID)%' accessKeySecret: '%env(AWS_SECRET_ACCESS_KEY)%' ``` -------------------------------- ### Configure Gitlab Client Service Source: https://github.com/1up-lab/oneupflysystembundle/blob/main/doc/adapter_gitlab.md Define the Gitlab client service in your application's configuration. Ensure you replace placeholder values with your actual project ID, branch, base URL, and personal access token. ```yaml services: acme.gitlab_client: class: RoyVoetman\FlysystemGitlab\Client arguments: - 'project-id' - 'branch' - 'base-url' - 'personal-access-token' ``` -------------------------------- ### Enable OneupFlysystemBundle in AppKernel Source: https://github.com/1up-lab/oneupflysystembundle/blob/main/doc/index.md Register the OneupFlysystemBundle within your Symfony application's kernel to enable its functionality. ```php filesystem = $acmeFilesystem; } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.