symfony - Symfony2.3, How to register a 3rd party bundle in Kernel, and load it from a Controller? -
I would like some help with symfony2 in relation to bundle registration in the kernel,
I've read Most symphony 2 cookbooks and doctor for example:
But still I failed to do so. I'm using Symphon 2.3 with composer, both dates.
Today I would like to use a third party bundle called "Google / AppCilient", for that I have the following line "google / Apiclient": "dev-master"
my composer. In the JSON file that is located in the root of my project.
To obtain an composer.phar update
bundle that was successfully downloaded and installed in the vendor repository
I think that So far I am doing fine, but the next step is where I am lost.
After this, I request to register this new bundle in App \ AppKernel.php for another, for example:
New Symphony \ Bundle \ Twangbundle \ Twig Bundle ()
But I do not know that new google \ apiclient ...
So the first question is what can I write there How should you understand it?
After doing this properly, I believe that now I am able to use it in the controller, but my second search is ion:
How to load .ppp which is located in seller / google / apiclient / src / Google?
All of this means, like in the example given in my controller, STH has to be enabled:
need_once 'Google / Client.php'; Need_once 'Google / Service / Books.php'; $ Client = new Google_Client (); $ Customer & gt; SetApplicationName ("Client_Library_Examples"); $ Customer & gt; SetDeveloperKey ("YOUR_APP_KEY"); $ Service = new Google_Service_Books ($ customer); $ OptParams = array ('filter' = & gt; 'free-e-book'); $ Result = $ service-> Volume-> List Volume ('Henry David Thoreau', $ Opt Piram); Forex Currency ($ $ $ as Item $ result) {echo $ item ['volumeInfo'] ['title'], "
; }
The goal is to be able to use the Google Contacts API in a symfony2 controller. Any help or suggestions are welcome, Cheers
People who like me do not understand how to load
I found that you want to use google / apiclient
-
I "google / apiclient" in my
composer.json
file. The following line is added under "dev-master" which is located in the root of my project. -
Set up the composer with the composer (in my case I used the command)
php composer.phar update
And it has become worthy ...
It is really easy, except to leave only one thing and load it by calling the class directly in its controller.
For example in my case.
I $ client = new Google_Client ();
, > wanted me need_once 'Google / Client.php';
But using Musician to set up the library, you can not see at all
'Google_Client' = & gt; $ Seller's '/google/apiclient/src/Google/Client.php',
So I have to do this in my Symphony Controller:
Important
Use Google_Client;
and then $ client = new Google_Client ();
and composer your autoload_classmap.php
or directly $ client = new \ Google_Client ();
I hope my experience will help to thank you for some of you, Cheers, and Tawki and @Waldikec @.
Comments
Post a Comment