PHP & Composer,如何组合 composer.json 文件



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

我该如何处理 composer.json 文件? 我是否手动组合它们?我只是将该作曲家.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"
}
}

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

"googleplus/quickstart": "*",

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

因此,我们可以说您不应该手动下载您的要求,您必须为此使用 Composer,它会为您处理。

相关内容

  • 没有找到相关文章

最新更新