Download the PHP package 2lenet/file-bundle without Composer
On this page you can find all versions of the php package 2lenet/file-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download 2lenet/file-bundle
More information about 2lenet/file-bundle
Files in 2lenet/file-bundle
Package file-bundle
Short Description File Bundle
License MIT
Homepage https://www.2le.net
Informations about the package file-bundle
FileBundle
Symfony bundle that standardize the way of handling data file associated with an entity
- Installation
- Customization
- Usage
Installation
The bundle is not yet on packagist make sure to add the following to your composer.json
file:
Install with composer:
Usage
in your controller or service juste use the fileManager to get the db and absolute path to use to store your data.
- This function take a first parameter which is the name of the store. Une one store for each field in each entity. It's a good practice to set a constant in the entitiy Class
- The second parameter is an object ( good to have a getId on it but not required ). Optionnally you can have a getDateForFilename to get the date to use for creating the folders.
- The third optionnal parameter is the extension to add to the file ( default .bin). Don't set the .
The function return a FileSpec object with two attribute
- dbPath is the path to use to store in your database ( relative from the projectDir )
- absPath is the filename to use to write your data ( open it with standard functions )
Path are build this way ( $projectDir / data / $storeName / Y / M / D / $objet->getId() . $ext ) if the folder does not exist it is created with the right right. Y/M/D is the year, month and day from the $object->getDateForFilename() if it exist, instead it use the today date.