Symfony2和Google API集成 [英] Symfony2 and Google API integration
问题描述
我要使用位于 http:// google- api-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.
可以导入此API与 composer
?
在我的应用程序中使用此API的最佳做法是什么?
What is the best practice to use this API with my application ?
推荐答案
这可能太晚了,但是没有必要使用forked git repos,你可以直接参考Google的nativesvn。
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
添加以下部分:
"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格式
"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
然后将以下行添加到您的require
部分:
Then add the following line to your "require"
section:
"require": {
...
"project/google-api-php-client": "1.0.0"
}
如果您希望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"]
}
把完整的路径放到全局的autoload部分看起来不是很整洁,但是我还没有设法使它在repository / package下的autoload部分工作:(
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屋!