In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail how Composer realizes automatic loading of projects. Xiaobian thinks it is quite practical, so share it with you as a reference. I hope you can gain something after reading this article.
Composer manages dependency packages and implements automatic loading
Composer adds and deletes dependent packages to a project through the require and remove commands.
Composer The PSR-4 auto-loading specification can be implemented by configuring the composer.json file in the project root directory.
Composer.json architecture details, here are details on how to configure the file.
By studying the source code of TP5.1, the automatic loading of TP5 is mainly based on the rewriting of the ClassLoader class produced by the composer under the vendor directory after the composer install command is executed. Composer automatic loading mechanism is to establish the mapping relationship between namespaces and files relative to the root directory path of the project, and then register the automatic loading of the system through the spl_autoload_register method. Among the automatic loading logic, the core is how to find the corresponding files according to the path generated above and include them.
Composer automatic loading detailed process:
● Configure the autoload autoload mapping rules in the composer.json file in the root directory.
Call composer install/update to generate the vendor/composer folder and related files. The mapping of namespaces to file paths is saved in the file autoload_psr4.php. At the same time, ClassLoader.php file is generated. This file is an automatically loaded tool class. By parsing the namespace, find the relevant files for inclusion.
● Include the autoload.php file under the vendor folder in the entry file. If you want to change the auto-loading related official, customize some operations, you can write a loader tool class according to the ClassLoader file generated by the composer, provided that you understand the auto-loading principle of the composer and the PSR4 auto-loading specification. For details, please refer to the implementation of Loader class in tp5.
About "Composer how to achieve automatic loading of the project" This article is shared here, I hope the above content can be of some help to everyone, so that you can learn more knowledge, if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.