Symfony 2 FilepickerIo Bundle
Installation
Step 1) Download bundle
Method a) Using composer (symfony 2.1 pattern)
Add on composer.json (see http://getcomposer.org/), (*1)
"require" : {
// ...
"webmil/filepickerio-bundle": "dev-master",
}
Method b) Using the deps
file (symfony 2.0 pattern)
Add the following lines to your deps
file and then run php bin/vendors
install
:, (*2)
[WebmilFilepickerIoBundle]
git=https://github.com/imsashko/WebmilFilepickerIoBundle.git
target=bundles/Webmil/FilepickerIoBundle
version=origin/2.0
Step 2) Register the namespaces
If you installed the bundle by composer, use the created autoload.php (jump to step 3).
Add the following namespace entry to the registerNamespaces
call
in your autoloader:, (*3)
<?php
// app/autoload.php
$loader->registerNamespaces(array(
// ...
'Webmil\\FilepickerIoBundle' => __DIR__.'/../vendor/bundles',
// ...
));
Step 3) Register the bundle
To start using the bundle, register it in your Kernel:, (*4)
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Webmil\FilepickerIoBundle\WebmilFilepickerIoBundle(),
);
// ...
}
# app/config/config.yml
webmil_filepicker_io:
api_key: yourKey
Usage
Initializing in twig template:
{{ filepicker_io_initialize() }}
Set type to 'filepicker' in form builder. To enable drag&drop set 'dragdrop' => true.
See the filepicker.io documentation for the full options list., (*5)
$form = $this->createFormBuilder()
->add('filepicker', 'filepicker', array(
'dragdrop' => true,
'attr' => array(
'data-fp-mimetype' => 'image/png'
)
))
->getForm();
Displaying an image:
{{ filepicker_io_image_tag('https://www.filepicker.io/api/file/hFHUCB3iTxyMzseuWOgG', {'w': '200'}, {'class': 'classname'}) }}
See the filepicker.io documentation for the full options list., (*6)
Allowing the user to download a file (or upload it to any of the supported services)
{{ filepicker_io_save_button('http://path/to/file.png', 'Download file', 'image/png', {'data-fp-suggestedFilename': 'name.png'}) }}
See the filepicker.io documentation for the full options list., (*7)