burzum / file-storage
This plugin is giving you the possibility to store files in virtually any kind of storage backend. This plugin is wrapping the Gaufrette library (https://github.com/KnpLabs/Gaufrette) library in a CakePHP fashion and provides a simple way to use the storage adapters through the StorageManager class.
Installs: 111 195
Dependents: 0
Suggesters: 0
Security: 0
Stars: 206
Watchers: 29
Forks: 87
Open Issues: 8
Type:cakephp-plugin
Requires
- php: >=7.2.0
- cakephp/cakephp: 4.x-dev as 4.0.0
- cakephp/plugin-installer: ^1.0.0
- knplabs/gaufrette: ^0.7.0|^0.8.0
Requires (Dev)
- aws/aws-sdk-php: *
- burzum/cakephp-imagine-plugin: 4.x-dev
- cakephp/cakephp-codesniffer: dev-next
- league/flysystem: ^1.0.0
- phpunit/phpunit: ^8.0
- vlucas/phpdotenv: ^3.3
Suggests
- burzum/cakephp-imagine-plugin: Required if you want to use the image processing feature of FileStorage
- league/flysystem: Alternative for Gaufrette, see the docs how to configure it.
- 4.0.x-dev
- 3.0.x-dev
- 3.0.0-beta
- 2.1.0
- 2.0.x-dev
- 2.0.0
- 2.0.0-rc1
- 2.0.0-beta2
- 2.0.0-beta1
- 2.0.0-alpha1
- 1.2.x-dev
- 1.2.1
- 1.2.0
- 1.1.x-dev
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.1.0-rc1
- 1.1.0-beta1
- 1.1.0-alpha1
- 1.0.x-dev
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- 1.0.0-RC1
- 0.5.2
- 0.5.1
- 0.5.0
- 0.4.2
- 0.4.1
- 0.4.0
- 0.3.3
- 0.3.2
- dev-4.0-fixes
- dev-0.0-cake2
- dev-master
This package is auto-updated.
Last update: 2022-03-25 02:38:26 UTC
README
If you're upgrading from CakePHP 2.x please read the migration guide.
The File Storage plugin is giving you the possibility to upload and store files in virtually any kind of storage backend. The plugin features the Gaufrette and FlySystem library in a CakePHP fashion and provides a simple way to use the storage adapters through the StorageManager class.
Storage adapters are an unified interface that allow you to store file data to your local file system, in memory, in a database or into a zip file and remote systems. There is a database table keeping track of what you stored where. You can always write your own adapter or extend and overload existing ones.
How it works
The whole plugin is build with clear Separation of Concerns (SoC) in mind: A file is always an entry in the file_storage
table from the app perspective. The table is the reference to the real place of where the file is stored and keeps some meta information like mime type, filename, file hash (optional) and size as well. Storing the path to a file inside an arbitrary table along other data is considered as bad practice because it doesn't respect SoC from an architecture perspective but many people do it this way for some reason.
You associate the file_storage
table with your model using the FileStorage or ImageStorage model from the plugin via hasOne, hasMany or HABTM. When you upload a file you save it to the FileStorage model through the associations, Documents.file
for example. The FileStorage model dispatches then file storage specific events, the listeners listening to these events process the file and put it in the configured storage backend using adapters for different backends and build the storage path using a path builder class.
List of supported Adapters
- Apc
- Amazon S3
- ACL Aware Amazon S3
- Azure
- Doctrine DBAL
- Dropbox
- Ftp
- Grid FS
- In Memory
- Local File System
- MogileFS
- Open Cloud
- Rackspace Cloudfiles
- Sftp
- Zip File
Supported CakePHP Versions
- CakePHP 4.x -> 3.0 Branch
- CakePHP 3.x -> 2.0 Branch
- CakePHP 2.x -> 1.0 Branch
Requirements
- PHP 7.2+
- CakePHP 4.x
- Gaufrette Storage Library 0.7.x
Optional but required if you want image processing out of the box:
- The Imagine Image processing plugin if you want to process and store images.
- FlySystem as alternative library over Gaufrette
You can still implement whatever file processing you want very easy. It's not tied to Imagine.
Documentation
For documentation, as well as tutorials, see the docs directory of this repository.
Support
For bugs and feature requests, please use the issues section of this repository.
Contributing
To contribute to this plugin please follow a few basic rules.
- Pull requests must be send to the branch that reflects the version you want to contribute to.
- Unit tests are required.
License
Copyright Florian Krämer
Licensed under The MIT License Redistributions of files must retain the above copyright notice.