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.
Composer
You 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.