如何使用Composer设置google-api-php-client? [英] How do I use Composer to setup google-api-php-client?

查看:208
本文介绍了如何使用Composer设置google-api-php-client?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说明中似乎存在一些空白,需要一点帮助吗?

There seems to be some gaps in the instructions, a little help?

步骤1: 轻松从PHP访问Google API ,听起来很简单!

Step 1: Easily access Google APIs from PHP, sounds easy!

步骤2:安装库,您可以安装通过将其添加为"composer.json"的依赖项来实现该库.从未听说过作曲家,从未使用过json.我需要做的就是在我的composer.json文件中添加"require":{"google/apiclient":"1.0.* @ beta"}

Step 2: Install the library, you can install the library by adding it as a dependency to your "composer.json". Never heard of composer, never used json. All I need to do is add "require": {"google/apiclient": "1.0.*@beta"} to my composer.json

第3步: Composer 需要Linux,但这并不是使用App Engine的全部目的,所以我不需要不得不对付Linux?好的,在Compute Engine上安装Debian,并添加以下内容:"sudo curl -sS https://getcomposer.org/installer | sudo php---install-dir =/usr/local/bin --filename = composer.

Step 3: Composer requires Linux, but isn't the whole point of using App Engine so I don't have to deal with Linux? Ok, setup Debian on Compute Engine and added the following, "sudo curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer" per the instructions.

步骤4: Composer基本用法 ...所有Google网页说要做的就是在Composer中添加以下内容,"require":{"google/apiclient":"1.0.*@beta"},所以这没有帮助.页面上的说明如下:

Step 4: Composer Basic usage... all the Google web page says to do is add the following to Composer, "require": {"google/apiclient": "1.0.*@beta"} so that's of no help. The instructions on the page say the following,

要在您的项目中开始使用Composer,您需要做的是 composer.json文件.此文件描述了您的依赖项 项目,并且可能还包含其他元数据.

To start using Composer in your project, all you need is a composer.json file. This file describes the dependencies of your project and may contain other metadata as well.

他们方便地忘记解释composer.json文件在哪里/什么?这只是人们自动知道的吗?

They conveniently forget to explain where/what is the composer.json file? Is this just something people automatically know?

我只想开始使用gogole-api-php-client,但是autoload.php文件从他们的网站上消失了,当我尝试手动进行操作时,它总是说我缺少GuzzleHttp/Collection.因此,我想我会尝试在Composer中将其放在一起,因为它是如此简单".有谁知道一整套简单的步骤/说明,而无需花费接下来的10个小时来学习json,composer和linux?有人真的有这个功能吗,因为我开始认为它甚至无效.这两个网站都需要放松对易"和简单"两个词的过度使用,因为我认为他们不理解这些词的含义. 过于复杂"和非常模糊"会更适合他们.

I just want to start using the gogole-api-php-client, but the autoload.php file is gone from their website, and when I try to do it manually it keeps saying I am missing GuzzleHttp/Collection. So I thought I would try to put it together in Composer because it's so "easy". Does anyone know of a simple set of steps/instructions to plow through this without spending the next 10 hours learning json, composer, and linux? Does anyone actually have this thing working, because I'm starting to think it doesn't even work. Both of these websites need to take ease off on their overuse of the words "easy" and "simple" because I don't think they understand the meaning of those words. "Excessively complicated" and "extremely vague" would suit them better.

推荐答案

文档似乎指向了错误的(不稳定的aka master)分支.您应该能够只安装v1-master分支并使其运行. HelloAnalytics 示例适用于v1-例如大师.

The documentation had been pointing to the wrong (unstable aka master) branch it seems. You should be able to just install the v1-master branch and get it running. The HelloAnalytics example should work with the v1-master for example.

git clone -b v1-master https://github.com/google/google-api-php-client.git

例如,如果您想运行不稳定分支,则可以更直接地回答标题中的问题- 将composer(composer.phar)安装到您的项目文件夹中,然后运行命令:

To answer your the question in the title more directly, if you for example want to run the unstable branch - Install composer (composer.phar) to your project folder and just run the command:

php composer.phar require "google/apiclient:~2.0@dev"

这将导致一个名为vendor的文件夹,其中将包含autoload.php.只要将此行包含在您的代码中,您就应该能够使其运行.

This should result in a folder called vendor which will contain autoload.php. Just include this row in your code and you should be able to get it running.

require_once 'vendor/autoload.php';

我对此很陌生,所以其他人也许可以更好地解释这一点.

I'm quite new to this so someone else might be able to explain this better.

这篇关于如何使用Composer设置google-api-php-client?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆