For people who like me couldn't figure out how to load a 3rd party library in a controller,
Here is what a did :
I wanted to use the google/apiclient found on packagist.org
I add the following line in
"google/apiclient": "dev-master"
under "require" to mycomposer.json
file which is located at the root of my project.Install the new library with composer ( in my case i used the command)
php composer.phar update
and it's done lol ...
it's really that easy, the only thing left is to load it in your controller by calling the class directly.
For exemple in my case.
I wanted to $client = new Google_Client();
,
I thought I had to use require_once 'Google/Client.php';
but not at all if you used composer to install the library you can find that /vendor/composer/autoload_classmap.php
return an array with the following line 'Google_Client' => $vendorDir . '/google/apiclient/src/Google/Client.php',
So all I have to in my symfony controller is to :
IMPORTANTuse Google_Client;
and then $client = new Google_Client();
and composer load it for me from its autoload_classmap.php
Or directly write $client = new \Google_Client();
I hope my experience will help some of you,
Cheers, and thanks to @Touki and @waldek_c .