将 Google API 的分析客户端库 PHP 集成到 Symfony2
Integrate Google API's Analytics Client Library PHP into Symfony2
我已成功完成以下 Google 文章,https://developers.google.com/analytics/devguides/reporting/core/v3/quickstart/service-php 并设置了用于提取 Analytics 数据的基本 php 脚本。这很容易:-)
我现在正尝试将此代码集成到我的 Symfony2 项目中。现在看来这个库是用古风写的,没有命名空间和文件名与其中的 class 不同。任何人都可以帮助我如何将它集成到我的 symfony 项目中吗?我已经通过 composer 使用以下内容加载到 git 存储库中:
"repositories": [
{
"type": "package",
"package": {
"name": "google/google-api-php-client",
"version": "1.1.4",
"dist": {
"url": "https://github.com/google/google-api-php-client/archive/1.1.4.zip",
"type": "zip",
"reference": "1.1.4"
}
}
}
],
但问题是所有的自动加载等
提前致谢!
该库有一个 composer.json
file and is registered in packagist,因此您只需在您的 composer 的 require 部分添加 "google/apiclient": "1.1.4"
,composer 将处理自动加载。
然后以正确的方式将其集成到 Symfony,请阅读文档 here 以了解如何在 services.yml
文件中注册您自己的服务。
将您的应用程序名称和密钥定义为 parameters.yml
中的参数,以便在您的服务定义中重用它们。
为您实例化的每个 class 定义一个服务(例如 Google_Client
、Google_Service_Analytics
、Google_Auth_AssertionCredentials
、...的服务)并正确依赖于其他服务服务 and/or 个参数。
注意:我在 knpbundles: isometriks/GoogleApiBundle and Happyr/GoogleApiBundle 上找到了这些捆绑包,它们可能会有所帮助。
我已成功完成以下 Google 文章,https://developers.google.com/analytics/devguides/reporting/core/v3/quickstart/service-php 并设置了用于提取 Analytics 数据的基本 php 脚本。这很容易:-)
我现在正尝试将此代码集成到我的 Symfony2 项目中。现在看来这个库是用古风写的,没有命名空间和文件名与其中的 class 不同。任何人都可以帮助我如何将它集成到我的 symfony 项目中吗?我已经通过 composer 使用以下内容加载到 git 存储库中:
"repositories": [
{
"type": "package",
"package": {
"name": "google/google-api-php-client",
"version": "1.1.4",
"dist": {
"url": "https://github.com/google/google-api-php-client/archive/1.1.4.zip",
"type": "zip",
"reference": "1.1.4"
}
}
}
],
但问题是所有的自动加载等
提前致谢!
该库有一个 composer.json
file and is registered in packagist,因此您只需在您的 composer 的 require 部分添加 "google/apiclient": "1.1.4"
,composer 将处理自动加载。
然后以正确的方式将其集成到 Symfony,请阅读文档 here 以了解如何在 services.yml
文件中注册您自己的服务。
将您的应用程序名称和密钥定义为 parameters.yml
中的参数,以便在您的服务定义中重用它们。
为您实例化的每个 class 定义一个服务(例如 Google_Client
、Google_Service_Analytics
、Google_Auth_AssertionCredentials
、...的服务)并正确依赖于其他服务服务 and/or 个参数。
注意:我在 knpbundles: isometriks/GoogleApiBundle and Happyr/GoogleApiBundle 上找到了这些捆绑包,它们可能会有所帮助。