Download the PHP package floppy/bundle without Composer
On this page you can find all versions of the php package floppy/bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download floppy/bundle
More information about floppy/bundle
Files in floppy/bundle
Package bundle
Short Description Floppy is a file storage library. This library adds fine support to use FloppyServer instance to Symfony2 apps.
License MIT
Informations about the package bundle
FloppyBundle
FloppyBundle provides few additional integration points with FloppyServer library. Before reading this documentation, you should read documentation for FloppyServer and FloppyClient first.
The main goal of Floppy-family libraries is to make dealing with every aspect of files as easy as possible. Floppy-family libraries improve dealing with: file uploading, file storing, generating various file versions (thumbnails, watermarks etc.), representing files in Entities and more.
Documentation
ToC
- Quick tour
- Integration points
- Form
- Doctrine column type
- Twig
- Configuration
- License
Quick tour
1) Configure your floppy server (shown in floppy-server doc)
2) Add floppy/bundle to your composer and register this bundle in AppKernel:
composer.json (stable version is recommended, "*" as a version is only an example).
app/AppKernel.php:
And that's all, next points explain how to use features of this bundle.
4) Define your form model or entity:
5) Use floppy_file
in your form type:
6) Create your action to handle this form
7) In action template you should add css and javascripts for this form:
8) Use your already created entity object and render file url:
Integration points
FloppyClient library adds two integration points with FloppyServer:
- url generation for files stored on FloppyServer
- client for file upload on FloppyServer
FloppyBundle adds additional 3 integration points:
- form type: floppy_file
- doctrine column type: floppy_file
- twig floppy_url() function and floppy_filter filter
Form
floppy_file form type allows you to upload and assign file to your entity object. The form type uses plupload library as javascript uploader by default. To set up floppy_file, you should include floppy styles (css file), jquery, plupload and FloppyFileFormType.js in your layout.
Example:
floppy_file has few options, the most important are:
- file_types - what file types that will be visible in file chooser dialog. This file types don't cause validation on server side, to validate file type you should use credentials. File types in this context are not exactly the same as file handler names (more about file handlers you can read in FloppyServer and FloppyClient docs). File types have following structure: { name: "Human readable name", extensions: [ "txt" ] }. You can define aliases to predefined file types in bundle configuration (floppy.form.file_type_aliases option, see more in "Configuration" section)
- transport_types - what javascript file transport should be used. Allowed values: html5, flash, silverlight and html4. Default value are all in the order as mentioned before. The order is important, because when browser doesn't support for example html5 transport, next transport on the list will be used.
- credentials - credentials for file uploading. Supported options for credentials are: expiration (upload request expiration timestamp), file_types (allowed file types - it will be validated on server side), access (public/private, should file be stored in public or in private storage). More about credentials you can find in FloppyServer and FloppyClient docs.
Doctrine column type
floppy_file column type simplify dealing with files in your entities. File in entity is represented by Floppy\Common\FileId object. The most interesting properties of FileId are:
- id - file hash + file extension, example: 5c7cd2fd39958b18a79f3c7e504d7cb2.jpg
- info - information about file (file size, mime type, image dimensions etc.), it only contains this information when FileId
comes from "floppy_file" form or
Floppy\Client\FloppyClient
::upload
() method, so you can in setter method store this additional info in other properties of entity
Example:
Twig
After upload file (thanks to floppy_file form type) and store it in your entity (thanks to floppy_file doctrine column type) you may want to display url to the file. floppy_url twig function is able to generate url to the file.
Examples of floppy_url usage:
Configuration
Only two options are required: floppy.endpoint.host and floppy.secret_key. There is a list of all configuration options:
License
This project is under MIT license.
All versions of bundle with dependencies
symfony/form Version ~2.1
symfony/framework-bundle Version ~2.1
doctrine/doctrine-bundle Version *
doctrine/orm Version ~2.0
symfony/twig-bridge Version ~2.1