How to remove unused dependencies from composer?

后端 未结 4 439
我在风中等你
我在风中等你 2020-12-07 07:54

I installed a package with composer, and it installed many other packages as dependencies.

Now I uninstalled the main package with composer remove packageautho

相关标签:
4条回答
  • 2020-12-07 08:43

    In fact, it is very easy.

    composer update
    

    will do all this for you, but it will also update the other packages.

    To remove a package without updating the others, specifiy that package in the command, for instance:

    composer update monolog/monolog
    

    will remove the monolog/monolog package.

    Nevertheless, there may remain some empty folders or files that cannot be removed automatically, and that have to be removed manually.

    0 讨论(0)
  • 2020-12-07 08:46

    Just run composer install - it will make your vendor directory reflect dependencies in composer.lock file.

    In other words - it will delete any vendor which is missing in composer.lock.

    Please update the composer itself before running this.

    0 讨论(0)
  • 2020-12-07 08:50

    following commands will do the same perfectly

    rm -rf vendor
    
    composer install 
    
    0 讨论(0)
  • 2020-12-07 08:53

    The right way to do this is:

    composer remove jenssegers/mongodb --update-with-dependencies
    

    I must admit the flag here is not quite obvious as to what it will do.

    Update

    composer remove jenssegers/mongodb
    

    As of v1.0.0-beta2 --update-with-dependencies is the default and is no longer required.

    0 讨论(0)
提交回复
热议问题