Download the PHP package uploadcare/uploadcare-zend2 without Composer

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

Uploadcare Zend Framework 2 Module

This is a module for Zend Framework 2 to work with Uploadcare

It's based on a uploadcare-php library.

Requirements

Install

GitHub

Clone module from git to your vendor directory:

git clone git://github.com/uploadcare/uploadcare-zend2.git vendor/Uploadcare --recursive

Composer

Update your composer.json:

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

Install package:

composer update

Fetch submodules from github:

cd vendor/uploadcare/uploadcare-zend2/ && git submodule init && git submodule update   

Edit your config/application.config.php and add new module. It should look like this:

return array(
    'modules' => array(
        'Application',
        'Uploadcare',
    ),
    'module_listener_options' => array(
        'config_glob_paths'    => array(
            'config/autoload/{,*.}{global,local}.php',
        ),
        'module_paths' => array(
            './module',
            './vendor',
        ),
    ),  

);

Inside your config/autoload/global.php add:

return array(
    'uploadcare' => array(
      'public_key' => 'demopublickey',
      'secret_key' => 'demoprivatekey',
    ),
);

Usage

You can access uploadcare api service inside a controller like this:

$uploadcare = $this->getServiceLocator()->get('uploadcare');

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

Create a from to show Uploadcare widget. Use UploadcareInput class as a field.

Inside your controller:

namespace Application\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Uploadcare\Form\UploadcareInput;
use Zend\Form\Form;

class IndexController extends AbstractActionController
{
    public function indexAction()
    {
        $uploadcare = $this->getServiceLocator()->get('uploadcare');

        //file_id is name of input for widget. 
        //You will recieve File ID at CDN from this field.
        $uploadcare_widget = new UploadcareInput('file_id');

        $form = new Form();
        $form->add($uploadcare_widget);
        $form->add(array('name' => 'submit',
          'attributes' => array(
            'type'  => 'submit',
            'value' => 'Upload!'
        )));

        return array(
          'form' => $form,
          'uploadcare' => $uploadcare,
        );
    }
}

Now we can display a form with a widget inside view:

<?php
$this->form->prepare();

echo $this->uploadcare->widget->getScriptTag();
echo $this->form()->openTag($form);
echo $this->formCollection($form);
echo $this->form()->closeTag();

"echo $this->uploadcare->widget->getScriptTag();" will display all <script> sections you need.

Now you are able to upload files using Uploadcare widget.

Let's handle file_id and display the file. Update your controller to look like this:

class IndexController extends AbstractActionController
{
    public function indexAction()
    {
        $uploadcare = $this->getServiceLocator()->get('uploadcare');

        $uploadcare_widget = new UploadcareInput('file_id');

        $form = new Form();
        $form->add($uploadcare_widget);
        $form->add(array('name' => 'submit',
          'attributes' => array(
            'type'  => 'submit',
            'value' => 'Upload!'
        )));

        $file = null;
        $request = $this->getRequest();
        if ($request->isPost()) {
          $form->setData($request->getPost()->toArray());
          if ($form->isValid()) {
            $data = $form->getData();
            $file_id = $data['file_id'];
            $file = $uploadcare->getFile($file_id); //get file from API
            $file->store(); //store file
          }
        }

        return array(
          'form' => $form,
          'uploadcare' => $uploadcare,
          'file' => $file,
        );
    }
}

Now we have an object of Uploadcare\File. Let's display it inside view:

echo $this->file->scaleCrop(300, 300, true)->getImgTag();

All versions of uploadcare-zend2 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-zend2 contains the following files

Loading the files please wait ....