Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
563 views
in Technique[技术] by (71.8m points)

symfony 2.1 - Symfony2 and Google API integration

I am going to use Google API located on http://google-api-php-client.googlecode.com/svn/trunk/ with my Symfony2 application.

Is it possible to import this API with composer ?

What is the best practice to use this API with my application ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It's probably too late, but there is no need to use forked git repos, you can refer to Google's "native" svn directly.

Add the following section to your 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"
            }
        }
    }
]

Notes:

  • "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

Then add the following line to your "require" section:

"require": {
    ...
    "project/google-api-php-client": "1.0.0"
}

That'll make composer to checkout the repo on the next update/install.

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"]
}

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 :(


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...