沃梦达 / 编程问答 / php问题 / 正文

如何指定 Composer 安装路径?

How to specify Composer install path?(如何指定 Composer 安装路径?)

本文介绍了如何指定 Composer 安装路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个定义:

{
    "repositories": [
        {
            "type": "package",
            "package": {
                "name": "symfony/sfGuardPlugin",
                "version": "4.0.2",
                "dist": {
                    "url": "http://plugins.symfony-project.org/get/sfGuardPlugin/sfGuardPlugin-4.0.2.tgz",
                    "type": "tar"
                }
            }
        }
    ],
    "require": {
        "symfony/sfGuardPlugin": "4.0.*"
    }
}

我正在使用 Symfony 1,我想将它们安装在 plugins/sfGuardPlugin/ 上.如何指定?

I am using Symfony 1, and I'd like to install them on plugins/sfGuardPlugin/. How do I specify this?

推荐答案

看来你可以定义 vendor 目录为 其他东西(你的情况是plugins):

It seems that you can define the vendor dir to be something else (plugins in your case):

{
    "config": {
        "vendor-dir": "plugins"
    }
}

然后,您可以将包名重命名为内部没有级别目录,例如:

Then, you might rename the package name to not have a level dir inside, like:

        "package": {
            "name": "sfGuardPlugin",

所以,你的 composer.json 应该是这样的:

So, your composer.json should look like this:

{
    "config": {
        "vendor-dir": "plugins"
    },
    "repositories": [
        {
            "type": "package",
            "package": {
                "name": "sfGuardPlugin",
                "version": "4.0.2",
                "dist": {
                    "url": "http://plugins.symfony-project.org/get/sfGuardPlugin/sfGuardPlugin-4.0.2.tgz",
                    "type": "tar"
                }
            }
        }
    ],
    "require": {
        "sfGuardPlugin": "4.0.*"
    }
}

编辑

使用这个配置,你会得到路径(这当然对symfony不好):

Using this configuration, you will get the path (which is of course not good for symfony):

plugins/sfGuardPlugin/sfGuardPlugin-4.0.2/

plugins/sfGuardPlugin/sfGuardPlugin-4.0.2/

我找到了一个使用这个 composer.json 的解决方法:

I found a workaround with this composer.json:

{
    "config": {
        "vendor-dir": "plugins"
    },
    "repositories": [
        {
            "type": "package",
            "package": {
                "name": "sfGuardPlugin",
                "version": "4.0.2",
                "source": {
                    "url": "http://svn.symfony-project.com/plugins/sfGuardPlugin/",
                    "type": "svn",
                    "reference": "branches/1.3/"
                }
            }
        }
    ],
    "require": {
        "sfGuardPlugin": "4.0.*"
    }
}

这篇关于如何指定 Composer 安装路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:如何指定 Composer 安装路径?

基础教程推荐