2017 © Pedro Peláez
 

symfony-bundle media-bundle

Help your application to upload file easier.

image

xiranst/media-bundle

Help your application to upload file easier.

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

XiranstMediaBundle

Help your application to upload file easier., (*1)

1, Installation with composer

$ composer require xiranst/media-bundle:dev-master

2, Enable in AppKernel.php

// app/AppKernel.php
<?php
    // ...
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new Xiranst\Bundle\MediaBundle\XiranstMediaBundle(),
        );
    }

3, Usage in Form Type

<?php 
// src/Xiranst/Bundle/DemoBundle/Form/YourFormType.php

namespace Xiranst\Bundle\DemoBundle\Form;

use Xiranst\Bundle\MediaBundle\Form\ThumbnailType;
class YourFormType extends AbstractType
{
    /**
     * {@inheritdoc}
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        // ...
        $builder->add('thumbnail', ThumbnailType::class);
        // ...
    }
    // ...
}

4, Options

a, Configure the upload directory in config.yml, (*2)

Default directory is:, (*3)

%kernel.root_dir%/../web/uploads/media

Please make the permission of web/uploads/media directory is 0777;, (*4)

If you need to change this path, please add this configuration in config.yml, (*5)

// app/config/config.yml
xiranst_media:
    upload_directory: '%kernel.root_dir%/../your-directory/'

b, if the file has uploaded and you want to display it in the form template, you can use this code:, (*6)

{{ form.vars.data.thumbnail }}

The Versions

12/04 2017

dev-master

9999999-dev http://www.xiranst.com

Help your application to upload file easier.

  Sources   Download

MIT

The Requires

 

bundle symfony image manipulation transformation pictures imagine photos upload image upload file upload media xiranst