drxnfdx798517235 2015-05-12 14:08
浏览 47

如何将程序包安装到我的框架的自定义路径?

I'm using composer version 1.0-dev

I read https://getcomposer.org/doc/faqs/how-do-i-install-a-package-to-a-custom-path-for-my-framework.md and https://github.com/composer/installershave

I have a custom module in bitbucket with this simple composer.json:

{
    "name": "mybitbucketuser/base",
    "type": "puppet-module",
    "require": {
        "composer/installers": "~1.0"
    }
}

In my main project I have this composer.json:

{
    "minimum-stability": "stable",
    "repositories": [
        {
            "type": "vcs",
            "url": "https://bitbucket.org/mybitbucketuser/fluzu-base.git"
        }
    ],
    "require": {
        "mybitbucketuser/base": "*"
    },
    "extra": {
        "installer-paths": {
            "modules/{$name}/": ["mybitbucketuser/base"]
        }
    }
}

I tried with this too:

"extra": {
    "installer-paths": {
        "modules/{$name}/": ["type:puppet-module"]
    }
}

All seems works fine but composer install the module in the default vendor dir instead in modules dir.

Whats wrong? Thanks.

By the way, I'm using type puppet-module but in reality is a phalcon module.

  • 写回答

2条回答 默认 最新

  • dpicx06888 2015-05-12 16:06
    关注

    I just made a test and it worked. Here is a simple example where hello-world is a package and hello-world-test requires that package.

    Folder structure

    /
      hello-world/
        src/
          HelloWorld/
            SayHello.php
        composer.json
    
      hello-world-test/
        composer.json
    

    /hello-world/src/HelloWorld/SayHello.php

    <?php 
    
    namespace HelloWorld;
    
    class SayHello
    {
        public static function world()
        {
            return 'Hello World, Composer!';
        }
    }
    

    /hello-world/composer.json

    {
        "name": "me/hello-world",
        "type": "puppet-module",
        "require": {
            "composer/installers": "~1.0"
        },
        "autoload": {
            "psr-0": {
                "HelloWorld": "src/"
            }
        }
    }
    

    Then I ran

    cd hello-world
    git init
    git add *
    git commit -m "Initial commit"
    git tag -a 1.0.0 -m "first stable version"
    

    Note: Composer expects a git repository here and also a version tag when the minimum-stability is set to stable. We can omit the tag if we set minimum-stability to dev.


    /hello-world-test/composer.json

    {
        "minimum-stability": "stable",
        "repositories": [
            {
                "type": "vcs",
                "url": "../hello-world"
            }
        ],
        "require": {
            "me/hello-world": "*"
        }
    }
    

    Then I ran

    cd hello-world-test
    composer install
    

    Composer now automatically created a vendor folder for composer/installers and a modules folder for our hello-world package. The modules folder is created because of "type": "puppet-module" in our package.

    评论

报告相同问题?

悬赏问题

  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 matlab有关常微分方程的问题求解决
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法