MechaStorm
MechaStorm

Reputation: 1482

Loading official Google PHP API Client as a Composer require

I am writing a library as a composer package that requirues the official PHP Google API Client. This api client can only be found on Github - the versions on packagists are simply forks and seems to not be updated often.

I am having a problem of adding the official API client as a dependency of a package. Any thoughts of what I am doing wrong?

{
    "name": "mechastorm/google-spreadsheet-extractor",
    "require": {
        "google/google-api-php-client": "dev-master"
    },
    "require-dev": {
        "google/google-api-php-client": "dev-master",
        "phpunit/phpunit": "~4.0",
        "mockery/mockery": "~0.9"
    },
    "minimum-stability" : "dev",
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/google/google-api-php-client.git"
        }
    ],
    "autoload": {
        "psr-0" : {
            "mechastorm\\google-spreadsheet-extractor" : "src"
        }
    }
}

The error I simply get is

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for mechastorm/google-spreadsheet-extractor dev-master -> satisfiable by mechastorm/google-spreadsheet-extractor[dev-master].
    - mechastorm/google-spreadsheet-extractor dev-master requires google/google-api-php-client dev-master -> no matching package found.

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.

Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

Upvotes: 0

Views: 1365

Answers (1)

JKaan
JKaan

Reputation: 329

Here you can see to include Google's PHP API you can just put this line into your composer.json require block

"google/apiclient": "1.0.*@dev"

Your solution should work too, however you should specify a different version.

If you use a git repository with composer you should specify a tag as the version number.

Upvotes: 1

Related Questions