Is it possible to ignore child dependencies in Composer config?

前端 未结 4 1310
独厮守ぢ
独厮守ぢ 2020-12-30 01:49

When I run composer install, it will install all my \"require\" and the \"require\" of the other package.

My composer.json

{
    \"name\": \"my_app\"         


        
相关标签:
4条回答
  • 2020-12-30 02:25

    Another option could be to modify the composer.json of the child package and to remove the required dependencies. Then you could host the zip file and add reference it by adding an extra repository for your main package.

    "repositories": [
        {
            "type": "package",
            "package": {
                "name": "dr-que/x-y",
                "version": "master",
                "dist": {
                    "type": "zip",
                    "url": "http://xyplot.drque.net/Downloads/XY_Plot-1.4.zip",
                    "reference": "master"
                },
                "autoload": {
                    "classmap": ["."]
                }
            }
        }
    ]
    

    Then in your require section, add your selected name as follows.

    "require": {
        "dr-que/x-y": "dev-master"
    }
    

    For the autoload, I just copied the same autoload section of the child package.

    The original solution can be found here

    0 讨论(0)
  • 2020-12-30 02:36

    I know that it's possible ignore the php extensions, but what about these second require package?

    Yes, you can use --ignore-platform-reqs to ignore php, hhvm, lib-* and ext-* platform requirements and force the installation, even if the local machine does not fulfill these.

    But, i'm not sure were you are heading with your question. What's the use-case for requiring a package without its dependencies in your application? Isn't this the main reason to use Composer?

    No, its not possible, unless you are looking for require --no-update, which disables the automatic update of the dependencies. Please take a look at the CLI options for require and install.

    0 讨论(0)
  • 2020-12-30 02:42

    You can ignore packages to be downloaded with the replace property of your composer.json: https://getcomposer.org/doc/04-schema.md#replace

    That way you tell composer, that you take or took care of that package's content on your own.

    This can help you to ignore a package your are sure you do not need, but it is kind of hacky. So be aware some things (like tests) might break. A better approach would be to request a patch from the maintainer of the original package to make the requirements optional (via the suggest property).

    edit:
    Example for "disabling" the requirement to zendframework/zend-mail:

    {
        "name": "my_app",
        "require": {
            "some/package": "0.0.0"
        },
        "replace": {
            "zendframework/zend-mail": "*"
        }
    }
    
    0 讨论(0)
  • 2020-12-30 02:42

    One more way to solve it:

    1. Clone package to your repository and fix dependencies
    2. In your composer.json add your repository:
    "repositories": [
        { "type": "git", "url": "https://github.com/zhovtyj/mailchimp-laravel" }
    ],
    "require": {
        "php": "^7.1.3",
        ***
        "skovmand/mailchimp-laravel": "dev-master",
    },
    
    0 讨论(0)
提交回复
热议问题