dptn69182
dptn69182
2012-08-09 12:23

如何指定Composer安装路径?

已采纳

I have this definition:

{
    "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.*"
    }
}

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

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

3条回答

  • dongxi7704 dongxi7704 9年前

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

    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.*"
        }
    }
    

    Edit

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

    plugins/sfGuardPlugin/sfGuardPlugin-4.0.2/

    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.*"
        }
    }
    
    点赞 评论 复制链接分享
  • duanli9569 duanli9569 9年前

    You can also use composer/installers, a multi-framework composer library installer with the "symfony1-plugin" package type. This is what my composer.json file looks like, in order for it to install both Symfony 1.4 (in lib/vendor) and plugins in (/plugins):

    {
        "config": {
            "vendor-dir": "lib/vendor"
        },
        "repositories": {
            "symfony": {
                "type": "package",
                "package": {
                    "name": "symfony/symfony1",
                    "version": "1.4",
                    "dist": {
                        "url": "https://github.com/symfony/symfony1/zipball/1.4",
                        "type": "zip"
                    }
                }
            },
            "sfResquePlugin" : {
                "type": "package",
                "package": {
                    "name": "devpips/sfResquePlugin",
                    "type": "symfony1-plugin",
                    "version": "0.1",
                    "dist": {
                        "url": "https://github.com/devpips/sfResquePlugin/zipball/master",
                        "type": "zip"
                    }
                }
            }
        },
        "require": {
            "composer/installers": "dev-master",
            "symfony/symfony1": "1.4",
            "devpips/sfResquePlugin":"0.1"
        }
    }
    
    点赞 评论 复制链接分享
  • dougua2309 dougua2309 5年前

    See COMPOSER_VENDOR_DIR environment variable.

    By setting this var you can make Composer install the dependencies into a directory other than vendor.

    Can be helpful in the case you want to override this in a particular environment such as vagrant where you wouldn't want this to be in a shared folder.

    And as J0k said, there's vendor-dir in config section of composer.json

    Defaults to vendor. You can install dependencies into a different directory if you want to. $HOME and ~ will be replaced by your home directory's path in vendor-dir and all *-dir options below.

    点赞 评论 复制链接分享

相关推荐