Home  >  Article  >  Development Tools  >  Analyze how composer can only update and load automatically?

Analyze how composer can only update and load automatically?

藏色散人
藏色散人forward
2021-12-06 16:00:142287browse

This article is written by the tutorial column of composer to introduce to you the problem of how composer only updates automatic loading without updating dependencies. I hope it will be helpful to friends in need!

Specific problem description:

composer only updates automatic loading without updating dependencies?

Added psr-4 automatic loading in composer.json

Then execute composer update to load the added directory

The dependent package will always be updated when executing update

How can we only update automatic loading without updating dependencies?

Solution:

composer dump-autoload

Print autoloading indexdump-autoload

In some cases you need to update the autoloader, For example, a new class is added to your package. You can use dump-autoload to do this without having to execute the install or update commands.

In addition, it can print an optimized index of classes that conform to the PSR-0/4 specification, which is also due to performance considerations. In large applications, there will be many class files, and the autoloader will take up a large part of the time of each request. Using classmaps may not be convenient during development, but it can still obtain PSR-0/ while ensuring performance. 4. Convenience brought by standards.

Print autoloading index - parameters

--optimize (-o): Convert PSR-0/4 autoloading to classmap for faster loading speed. This is particularly suitable for production environments, but may take some time to run, so it is not currently the default.

--no-dev: Disable autoload-dev rules.

The above is the detailed content of Analyze how composer can only update and load automatically?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete