Download the PHP package uploadcare/uploadcare-symfony2 without Composer

On this page you can find all versions of the php package uploadcare/uploadcare-symfony2. 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 uploadcare-symfony2

Uploadcare Symfony2 Bundle

This is a bundle for Symfony2 to work with Uploadcare

It's based on a uploadcare-php library.

Requirements

Install

GitHub

Clone bundle from git to your vendor directory:

git clone git://github.com/uploadcare/uploadcare-symfony2.git vendor/uploadcare/uploadcare-symfony2 --recursive

Composer

Update "require" section inside your composer.json:

"require": {
  "uploadcare/uploadcare-symfony2": "dev-master"
}   

Now tell composer to download package:

php composer.phar update

Add fetch git submodules:

cd vendor/uploadcare/uploadcare-symfony2 && git init && git update 

Edit your app/autoload.php. Add this:

$loader->add('Uploadcare', __DIR__.'/../vendor/uploadcare/uploadcare-symfony2/uploadcare/src');

Inside your app/config/config.yml add:

parameters:
    uploadcare.public_key: demopublickey
    uploadcare.secret_key: demoprivatekey

services:
    uploadcare:
      class: Uploadcare\UploadcareBundle\UploadcareSymfony
      arguments: [%uploadcare.public_key%, %uploadcare.secret_key%]

This will add Uploadcare Bundle as a service.

Usage

You can access this service inside a controller like this:

$this->get('uploadcare');

It will return a UploadcareSymfony object. This class extends Uploadcare\Api class.

Create some entity:

namespace UploadcareTest\UploadcareTestBundle\Entity;

class UCFile
{
  public $file_id;
}

Create form inside your controller:

namespace UploadcareTest\UploadcareTestBundle\Controller;

use Uploadcare\UploadcareBundle\Form\Type\UploadcareWidgetType;

public function indexAction()
{
    $uc_file = new UCFile();
    $form = $this->createFormBuilder($uc_file)
                 ->add('file_id', new UploadcareWidgetType())
                 ->getForm();

    return $this->render('UploadcareTestBundle:Default:index.html.twig', array(
        'form' => $form->createView(),
        'uploadcare' => $this->get('uploadcare'),
    ));
}

You can see a UploadcareWidgetType. It's a hidden field with special parameters to activate widget

To display widget and forms create a view for controller:

{% extends '::base.html.twig' %}
{% block body %}
<form action="{{ path('uploadcare_test_homepage') }}" method="post" {{ form_enctype(form) }}>
    {{ form_widget(form) }}

    <input type="submit" />
</form>
{% endblock %}
{% block javascripts %}
  {{ uploadcare.widget.getScriptTag|raw }}
{% endblock %}

Now you should be able to see a widget. Just upload some file and submit form.

To process file edit a controller to look like this:

public function indexAction()
{
    $uc_file = new UCFile();
    $form = $this->createFormBuilder($uc_file)
                 ->add('file_id', new UploadcareWidgetType())
                 ->getForm();

    $file = null;
    $request = $this->getRequest();
    if ($request->getMethod() == 'POST') {
      $form->bind($request);

      if ($form->isValid()) {
        $data = $request->request->get('form');
        $file_id = $data['file_id'];
        $file = $this->get('uploadcare')->getFile($file_id);
        $file->store();
      }
    }

    return $this->render('UploadcareTestBundle:Default:index.html.twig', array(
        'form' => $form->createView(),
        'uploadcare' => $this->get('uploadcare'),
        'file' => $file,
    ));
}

The main part is using a "getFile" method to create "$file" and then "store" method on file.

By calling "store" method you told Uploadcare to store file and it will be available at CDN.

You can pass "$file" to the twig template. "$file" is and object of Uploadcare\File.

With use of this object you can call any operations with file and display the file inside template like this:

{{ file.resize(400, 400).getImgTag|raw }}

All versions of uploadcare-symfony2 with dependencies

PHP Build Version
Package Version
Requires php Version >=5.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 uploadcare/uploadcare-symfony2 contains the following files

Loading the files please wait ....