Download the PHP package modera/file-repository-bundle without Composer
On this page you can find all versions of the php package modera/file-repository-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package file-repository-bundle
ModeraFileRepositoryBundle
This bundle provides a high level API for putting your files to virtual file repositories which internally use Gaufrette filesystem abstraction layer.
Installation
Step 1: Download the Bundle
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Step 2: Enable the Bundle
This bundle should be automatically enabled by Flex.
In case you don't use Flex, you'll need to manually enable the bundle by
adding the following line in the config/bundles.php
file of your project:
And finally check your config/packages/validator.yaml
and make sure that validation service is enabled:
Documentation
This bundle proves useful when you need to have a consistent way of storing your files with an ability to later reference these files in your domain model or query them (using Doctrine ORM). Configuration process consists of two steps:
- Configuring Gaufrette filesystem adapter
- Creating a virtual repository
This is a sample filesystem configuration using Gaufrette which creates a filesystem which will use local
/path/to/my/filesystem
path to store files:
Once low-level filesystem is configured you can create a repository that will manage your files:
When a physical file is put to a repository its descriptor record is created in database that later you can use in your domain logic. For example, having a Doctrine entity which represents a physical may prove useful when you have a user and you want to associate a profile picture with that user. Also it is worth mentioning that once StoredFile entity is removed, its physical file stored in a configured filesystem will be automatically removed as well. This descriptive record saved in database contains a bunch of useful information like mime-type, file extension etc, please see StoredFile's entity fields for more details.
Repository configuration
When you create a repository you can use these configuration properties to tweak behaviour of your repository:
- filesystem -- Gaufrette's filesystem name that this repository should use to store files
- storage_key_generator -- DI service ID of class which implements
Modera\FileRepositoryBundle\Repository\StorageKeyGeneratorInterface
interface. This class is used to generate filenames that will be used by filesystem to store files. If this configuration property is not provided when repository is created thenModera\FileRepositoryBundle\Repository\UniqidKeyGenerator
class will be used. - images_only -- if set to TRUE then it only will be possible to upload images to a repository.
- max_size -- if specified it won't be possible to upload files whose size exceeds given value. For megabytes use "m" prefix, for kilobytes - "k" and if no prefix is provided then bytes will be used, for example: 100k, 5m, 800.
- file_constraint -- Configuration options of File constraint.
- image_constraint -- Configuration options of Image constraint.
- interceptors -- allows to specify additional interceptors to use, values must be service container IDs
Command line
Bundle ships commands that allow you to perform some standards operations on your repositories and files:
- modera:file-repository:create
- modera:file-repository:list
- modera:file-repository:delete-repository
- modera:file-repository:put-file
- modera:file-repository:list-files
- modera:file-repository:download-file
- modera:file-repository:delete-file
- modera:file-repository:generate-thumbnails
Thumbnails generation
Bundle contains an interceptor that you can use to have thumbnails automatically generated for images when they are stored in a repository, to enable this feature when creating a new repository you need to use modera_file_repository.interceptors.thumbnails_generator.interceptor interceptor:
Configuration key "thumbnail_sizes" can be used to specify what thumbnail size you need to have. With this configuration
whenever a picture is uploaded to a repository alternative will be created, for more details see StoredFile::$alternatives,
StoredFile::$alternativeOf properties. If you already have a repository and you want to generate thumbnails for it
then use modera:file-repository:generate-thumbnails
command.
Licensing
This bundle is under the MIT license. See the complete license in the bundle: Resources/meta/LICENSE
All versions of file-repository-bundle with dependencies
doctrine/orm Version ^2.5
doctrine/doctrine-bundle Version ^1.6|^2.0
symfony/framework-bundle Version ^3.4|^4.0
knplabs/knp-gaufrette-bundle Version ^0.5
imagine/imagine Version ^1.0