I'm using Cloudinary to manage direct image uploads in my Sf2 application.
There's a Cloudinary helper function called "cl_image_upload_tag" that generates the upload form.
I need to run the function in my controller and display the results as raw code in my template. But I'm not able to access the function in my Controller
$cloud_form = \Cloudinary\Uploader::cl_image_upload_tag('image_id', array("callback" => $this->get("router")->generate("cloudinary_callback")));
(I will output $cloud_form in Twig as {{ cloud_form|raw }} )
I think this is a namespace issue but I can't make it work, it get "Error: Call to undefined method". Thanks!
Update: here's the autoload file:
<?php
use Doctrine\Common\Annotations\AnnotationRegistry;
use Composer\Autoload\ClassLoader;
/**
* @var $loader ClassLoader
*/
$loader = require __DIR__.'/../vendor/autoload.php';
AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
return $loader;
cl_image_upload_tagisn't a method of the Uploader class, it's just a function defined in Uploader.php, which is the same file that holds the Uploader class.Assuming that you include Uploader.php at the top of you controller, you can just call the function directly:
If you are using composer to vendor the Cloudinary package, Composer may take care of adding those functions to your application without the need to include the file in your controller.