cesurapp / storage-bundle
Symfony storage bundle
Installs: 242
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=8.2
- ext-fileinfo: *
- async-aws/s3: ^2.0
- symfony/dependency-injection: ^7.0
- symfony/framework-bundle: ^7.0
- symfony/http-kernel: ^7.0
Requires (Dev)
- php-cs-fixer/shim: ^3.40
- phpstan/phpstan: ^1.10
- symfony/test-pack: ^1.1
README
It is used for file storage. There is no database connection. Async-aws/s3 package is used for S3 connection. Tests are available for each driver, any test without access codes is skipped. You can use multiple drives at the same time. Use MediaBunle to keep track of files.
Supported Drivers
- BackBlaze
- CloudFlare
- Local
Install
Required Symfony 7
composer req cesurapp/storage-bundle
Configuration
# config/packages/storage.yaml storage: default: main devices: local: driver: local #backblaze, cloudflare, local root: "%kernel.project_dir%/storage/files" main: driver: s3 root: / accessKey: "access_key" secretKey: "secret_key" bucket: "bucket_name" region: "auto" endPoint: "https://11d0547262baad2e6bdeb340e88f83be.r2.cloudflarestorage.com" backblaze: driver: backblaze root: / accessKey: "access_key" secretKey: "secret_key" bucket: "bucket_name" region: "auto"
Tests
Tests for which access codes are not defined are skipped.
<!--phpunit.xml.dist--> <!--BackBlaze Test Keys--> <server name="BACKBLAZE_ACCESS_KEY" value="KEY"/> <server name="BACKBLAZE_SECRET" value="KEY"/> <server name="BACKBLAZE_BUCKET" value="KEY"/> <!--CloudFlare Test Keys--> <server name="CLOUDFLARE_R2_ACCESS_KEY" value="KEY"/> <server name="CLOUDFLARE_R2_SECRET" value="KEY"/> <server name="CLOUDFLARE_R2_ENDPOINT" value="KEY"/> <server name="CLOUDFLARE_R2_BUCKET" value="unit-test"/>
Usage
public function controllerAction(\Cesurapp\StorageBundle\Storage\Storage $storage) { // Upload File $storage->upload('source_path', 'upload_path'); // Write File $storage->write('upload_path', 'text_content', 'application/text'); // Delete $storage->delete('file_path'); // Check $storage->exists('file_path'); // Read $storage->read('file_path') }