Does php still need to write the autoload method after using composer?

Source: Internet
Author: User
Tags autoload
Recently, after seeing the composer, do I need to write the autoload method myself after I struggle to use composer in php? Or are all loaded with composer? In fact, I don't know much about composer. Please advise. Recently, after seeing the composer, do I need to write the autoload method myself after I struggle to use composer in php? Or are all loaded with composer? In fact, I don't know much about composer. Please advise.

Reply content:

Recently, after seeing the composer, do I need to write the autoload method myself after I struggle to use composer in php? Or are all loaded with composer? In fact, I don't know much about composer. Please advise.

No
The autoload function is available in the automatically generated vendor directory and is loaded according to the namespace.

ComposerYou have already generated a loader for you, so you don't have to write the loader yourself, the/vendor/composer directory contains the autoload_real.php file, which is mainly used to realize the ing between the namespace and the file path according to the four standards of psr-4/psr-0/classmap/files, of course, the current main psr-4 standard file is autoload_psr4.php, psr-0 standards to be eliminated. View the file source code in the/vendor/composer directory and place the loaded path data in the private variable of the ClassLoader object in sequence. Through $ loader-> register (true), spl_register_autoload () is actually used ().

Two articles are recommended: automatic loading of Laravel Execution Process (1), in-depth into Composer autoload. The two articles are well written. You can study them.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.