How do I use Composer to setup google-api-php-client?

帅比萌擦擦* 提交于 2019-12-06 05:00:56

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

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"

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.

Brent Shaffer

Sorry for the confusion, we've updated the docs to make this more clear.

We recommend using composer because it is the standard package manager for PHP these days. The other comment here details that process really well.

Another way is to go to Releases, and any package marked google-api-php-client-[RELEASE_NAME].zip will include all the dependencies. Download and extract this file, include the autoloader (at vendor/autoload.php), and you'll be all set!

Let me know if you run into any problems.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!