Symfony2 and Google API integration
Solution 1
It's probably too late, but there is no need to use forked git repos, you can refer to Google's "native" svn directly.
Add the following section to your composer.json
:
"repositories": [
{
"type": "package",
"package": {
"name": "project/google-api-php-client",
"version": "1.0.0",
"source": {
"type": "svn",
"url": "http://google-api-php-client.googlecode.com/svn",
"reference": "trunk"
}
}
}
]
Notes:
-
"project/google-api-php-client"
name there can be any of your choice - If you need a particular revision, use "trunk@revision-number-here" format in "reference" entry
Then add the following line to your "require"
section:
"require": {
...
"project/google-api-php-client": "1.0.0"
}
That'll make composer to checkout the repo on the next update/install.
If you want Google API classes to be autoloaded, add the following line to your "autoload" section:
"autoload": {
...
"classmap": ["vendor/project/google-api-php-client/src"]
}
It doesn't seem very neat to put the full path into the global "autoload" section, but I didn't manage to make it work with "autoload" section under `repository/package" yet :(
Solution 2
Google have now started using github and have added a composer.json file.
Github: https://github.com/google/google-api-php-client
Packagist: https://packagist.org/packages/google/apiclient
"require": { ... "google/apiclient": "dev-master" }
It's a shame there is no namespaces, but they are closer than before by having a composer file.
Solution 3
There is a Symfony2 bundle wrapping the official Google API library published by Google on Github in 2014. That way, the API client is available as a service and you can store your configuration in the Symfony2 config file.
Symfony2 Bundle: https://github.com/Happyr/GoogleApiBundle
$ composer require happyr/google-api-bundle
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new HappyR\Google\ApiBundle\HappyRGoogleApiBundle(),
);
}
Related videos on Youtube
hsz
IntelliJ SDK, Kotlin, Java, TypeScript, NodeJS, security, ...
Updated on September 15, 2022Comments
-
hsz over 1 year
I am going to use Google API located on http://google-api-php-client.googlecode.com/svn/trunk/ with my Symfony2 application.
Is it possible to import this API with
composer
?What is the best practice to use this API with my application ?
-
Jeroen about 11 yearsFrom the maintainer: Important note I've never completed this, and have no interest in further maintaining it. Please don't start anything new based on this. I'm keeping this repository around for the people who may still need it.
-
Jeroen about 11 yearsgithub.com/mybuilder/google-api-php-client seems to be an up to date version of it
-
Yuriy almost 11 yearsAdded autloader settings details.
-
Dmitry over 10 yearsWell, I believe you must have svn installed in your system to grab packages from svn repository. From getcomposer.org/doc/05-repositories.md#git-alternatives To get packages from these systems you need to have their respective clients installed.
-
Dmitry over 10 yearsTo install it without any external tool you can specify a path to the archive, e.g. google-api-php-client.googlecode.com/files/… Take a look at the example code.google.com/p/google-api-php-client/issues/detail?id=187#c5 Also consider local classmap section
-
Daniel P over 9 years"Starting January 1st, 2015, the PHP Ads client library will stop supporting PHP 5.2".
-
Jonny over 8 yearsThis is the up-to-date repository published by Google: github.com/google/google-api-php-client