Symfony2 和 Google API 集成 [英] Symfony2 and Google API integration
问题描述
我将使用位于 http://google- 上的 Google APIapi-php-client.googlecode.com/svn/trunk/ 与我的 Symfony2 应用程序.
I am going to use Google API located on http://google-api-php-client.googlecode.com/svn/trunk/ with my Symfony2 application.
是否可以使用 composer
导入此 API?
Is it possible to import this API with composer
?
在我的应用程序中使用此 API 的最佳做法是什么?
What is the best practice to use this API with my application ?
推荐答案
可能已经来不及了,但是没有必要使用forked git repos,可以直接参考谷歌的原生"svn.
It's probably too late, but there is no need to use forked git repos, you can refer to Google's "native" svn directly.
将以下部分添加到您的 composer.json
:
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"
}
}
}
]
注意事项:
"project/google-api-php-client"
名称可以任意选择- 如果您需要特定修订版,请在参考"条目中使用trunk@revision-number-here"格式
然后将以下行添加到您的 "require"
部分:
Then add the following line to your "require"
section:
"require": {
...
"project/google-api-php-client": "1.0.0"
}
这将使 Composer 在下一次更新/安装时检查存储库.
That'll make composer to checkout the repo on the next update/install.
如果您希望自动加载 Google API 类,请将以下行添加到您的自动加载"部分:
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 :(
这篇关于Symfony2 和 Google API 集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!