Download the PHP package iphp/filestore-bundle without Composer

On this page you can find all versions of the php package iphp/filestore-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package filestore-bundle

IphpFileStoreBundle - Symfony 2 Doctrine ORM file upload bundle

Build Status Total Downloads Code Climate

The IphpFileStoreBundle is a Symfony2 bundle that automates file uploads that are attached to an entity. The bundle will automatically name and save the uploaded file according to the configuration specified on a per property basis using a mix of configuration and annotations. After the entity has been created and the file has been saved, array with data of uploaded file will be saved to according property. The bundle provide different ways to naming uploaded files and directories.

For Russian documentation see http://symfonydev.ru/iphpfilestorebundle/

Installation

Get the bundle

Add the following lines in your composer.json:

Initialize the bundle

To start using the bundle, register the bundle in your application's kernel class:

Usage

IphpFileStoreBundle try to handle file uploads according to a combination of configuration parameters and annotations. In order to have your upload working you have to:

Configuration

The upload_dir and upload_path is the only required configuration options for an entity mapping.

All options are listed below:

Annotate Entities

In order for your entity to work with the bundle, you need to add a few annotations to it. First, annotate your class with the Uploadable annotation. This lets the bundle know that it should look for files to upload in your class when it is saved, inject the files when it is loaded and check to see if it needs to remove files when it is removed. Next, you should annotate the fields which hold the instance of Symfony\Component\HttpFoundation\File\UploadedFile when the form is submitted with the UploadableField annotation. The UploadableField annotation has a few required options. They are as follows:

Lets look at an example using a fictional Photo ORM entity:

recommended use case - upload in one field (uploadPhoto), store file data in another field (photo)

deprecated use case - upload and store file data in one field (photo)

Source code of Photo entity in test bundle

Field with file data must have type=array.

Uploaded file data

Аfter file upload annotated field contains array with elements:

If uploaded file im image, array also contains:

Using file data

To get a path for the file you can use this PHP code:

or in a Twig template:

Example of using entities with uploadable can be seen in controller and twig template for uploading and editing entities.

Example of interface with list of uploaded photos

interface with list of uploaded photos

Using form field type

Form field type Iphp\FileStoreBundle\Form\Type\FileType can be used in admin class, created for SonataAdminBundle. If entity already has uploaded file - information about this file will be displayed. Also delete checkbox allows to delete uploaded file.

Example of sonata admin form for uploaded photo

Example of edit form for uploaded photo

Customizing form field

For example we want show preview of original uploaded image, preview generated with LiipImagineBundle https://github.com/liip/LiipImagineBundle. For change <img src=".."> of preview we need to modify original form field template wich defined in https://github.com/vitiko/IphpFileStoreBundle/blob/master/Resources/views/Form/fields.html.twig.

When customizing the form field block in Twig, you have two options on where the customized form block can live:

Method 1: Form theming

The easiest way to customize the iphp_file_widget block is to customize it directly in the template that's actually rendering the form.

more info about form customization here http://symfony.com/doc/current/form/form_customization.html#form-theming

Method 2: Override bundle template

To override the bundle template, just copy the field.html.twig template from the vendor/iphp/filestore-bundle/Iphp/FileStoreBundle/Resources/views/Form/fields.html.twig to app/Resources/IphpFileStoreBundle/views/Form/fields.html.twig (the app/Resources/IphpFileStoreBundle directory won't exist, so you'll need to create it). You're now free to customize the template.

for example, for display preview in all forms

more info about overriding templates from third-party bundle here http://symfony.com/doc/current/templating/overriding.html

Namers

The bundle uses namers to name the files and directories it saves to the filesystem. If no namer is configured for a mapping, the bundle will use default transliteration namer for files was uploaded. if you would like to change this then you can use one of the provided namers or implement a custom one.

File Namers

Translit

Transliteration - replace cyrillic and other chars to ascii

To cancel transliteration

Using entity field value

File name by value of entity field ( field name - title)

Adding entity field value

Adding to the beginnng (propertyPrefix) or end (propertyPostfix) of file name value of entity field

Using entity field name

One mapping can be used in multiple fields. Name of the field can be used for naming file

Replacing strings

Params of replace namer are key-value pairs with search and replace strings

Directory Namers

Create subdirectory by date

For example: Uploaded file 123.jpg, entity createdAt field value 2013-01-01 - path to file will be 2013/01/123.jpg. Depth options - year, month, date.

Using entity field value

Using entity field name

Using entity class name

Using chain of directory namers

Using entity class name and entity field name


All versions of filestore-bundle with dependencies

PHP Build Version
Package Version
Requires php Version ^5.5 || ^7.0
symfony/framework-bundle Version ^2.8|^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package iphp/filestore-bundle contains the following files

Loading the files please wait ....