Reputation: 726
I am working on a Symfony 2.2 Project in which I need to upload video to Vimeo. I am using advanced Vimeo API via the Vimeo.php (official library of Vimeo)
I managed to add a namespace to the library and added it to the entity folder in my bundle because that is the only way the project was detecting the library.
<?php
**namespace MediaBundle\Entity;**
use Symfony\Component\Security\Core\Exception\InvalidCsrfTokenException as Exception;
class Vimeo
{
.... Vimeo.php Code ....
}
?>
I am trying to find a better way to integrate this library in my code. I have tried to place in the vendor/vimeo folder and autoload it from app/autoload.php
Without Namespace:
$loader->registerPrefixes(array(
'Vimeo_' => __DIR__.'/../vendor/vimeo/lib',
));
With Namespace:
$loader->registerNamespaces(array(
'Vimeo' => __DIR__.'/../vendor/vimeo/lib',
));
The class is still not recognized in the controller.
To automate the process I tried using a composer package dukt/vimeo, it is basically the same library just wrapper into composer. It places it in the autoload_namespaces.php, but I am still unable to use it in any controller. It is always not found.
Perhaps I am not putting the correct use statement. The autoload_namespaces.php code is:
'Dukt\\Vimeo' => $vendorDir . '/dukt/vimeo/src/',
There is a Vimeo.php class in /dukt/vimeo/src
with namespace Dukt;
. What should be my use statement in the controller?
Please let me know what is the best way to integrate a 3rd party library into my Symfony2 projects. I would continue using it via entity, but I am getting some errors, I think the API is not working properly from entity due to come callback path errors. I could be wrong though. None the less I'd like to properly include it.
Upvotes: 2
Views: 1853
Reputation: 44841
Install the wrapper package via Composer. It will handle all the autoloading stuff.
Upvotes: 2