3

有人可以解释一下我应该如何将作曲家与 php.ini 一起使用。我的文档根目录中有一个 composer.json 文件,它为我的项目下载核心包,但是当我想添加另一个项目时,如 google+ php sdk 在这里找到https://github.com/googleplus/gplus-quickstart-php /

我该如何处理 composer.json 文件?我要手动组合它们吗?我只是将 composer.json 下载到不同的目录中吗?

我当前的 composer.json 文件看起来像这样

 {
"name": "fuel/fuel",
"type": "metapackage",
"description": "The FuelPHP framework",
"keywords": ["framework"],
"homepage": "http://fuelphp.com",
"license": "MIT",
"authors": [
    {
        "name": "FuelPHP Development Team",
        "email": "team@fuelphp.com"
    }
],
"support": {
    "irc": "irc://irc.freenode.org/fuelphp",
    "forum": "http://fuelphp.com/forums"
},
"require": {
    "php": ">=5.3.3",
    "monolog/monolog": "1.5.*",
    "fuelphp/upload": "2.0",
    "omissis/php-cloudfiles": "dev-master",
    "mustache/mustache": "*"
},
"suggest": {
    "mustache/mustache": "Allow Mustache templating with the Parser package",
    "smarty/smarty": "Allow Smarty templating with the Parser package",
    "twig/twig": "Allow Twig templating with the Parser package",
    "mthaml/mthaml": "Allow Haml templating with Twig supports with the Parser package"
},
"config": {
    "vendor-dir": "fuel/vendor"
},
"minimum-stability": "dev"
}

g+ composer.json 文件看起来像

 {
"name": "googleplus/quickstart",
"description": "This quick-start app is built in PHP and lets you get started with the Google+ platform in a few minutes.",
"license": "Apache-2.0",
"repositories": [
    {
        "type": "package",
        "package": {
            "name": "google/google-api-php-client",
            "version": "0.6.2",
            "dist": {
                "url": "http://google-api-php-client.googlecode.com/files/google-api-php-client-0.6.2.tar.gz",
                "type": "tar"
            },
            "autoload": {
                "classmap": [
                    "src/"
                ]
            }
        }
    }
],
"require": {
    "silex/silex": "1.0.*@dev",
    "twig/twig": ">=1.8,<2.0-dev",
    "google/google-api-php-client": "0.6.2"
}
}
4

2 回答 2

6

只需将其添加到原始作曲家文件的 require 块中:

"googleplus/quickstart": "*",
于 2013-10-25T06:17:23.040 回答
2

我对 Composer 几乎没有经验,但我可以告诉你,当你需要一个库时,你可以将该库添加到你的主 composer.json 文件中。安装或更新后,将下载新的 lib,Composer 将读取其 composer.json 文件;它的依赖将被自动下载,依此类推。

所以我们可以说你不应该手动下载你的需求,你必须使用 Composer,它会为你处理它。

于 2013-10-25T06:23:30.107 回答