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

Analyze how composer can only update and load automatically?

藏色散人
Release: 2021-12-06 16:00:14
forward
2359 people have browsed it

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
Copy after login

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!

Related labels:
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template