In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you how to automatically load composer, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to understand it!
Four ways of automatic loading of composer
Composer is a package dependency management tool for PHP, similar to node.js 's npm. It's not official, but it's already very popular.
Composer provides four kinds of support for the automatic loading of third-party packages. They are psr-0,psr-4, generate class-map, and directly contain files
Psr-0 automatic loading
Psr-1 basic Code Specification
Psr-2 code style specification
Psr-3 log interface
Psr-4 automatic loading
The main difference between psr-0 and psr-4 is that there is no processing for underscores in psr-4. The underscore in psr-0 is escaped as a directory separator
Write in the main file index.php
Require 'vendor/autoload.php'
1.PSR-4
This is how it is configured in composer.json
{"aotuload": {"psr-4": {"FOO\": "src/"}
When you new FOO the class\ A\ An in index.php. Composer will look for src/A/A.php. If this file exists, load it
2.PSR-0
This is how it is configured in composer.json
{"aotuload": {"psr-0": {"FOO\": "src/"}
When you new FOO the class\ A\ An in index.php. Composer will look for src/FOO/A/A.php. If this file exists, load it
3.class-map
{"aotuload": {"class-map": ['a class-map']}}
Composer scans the abc directory for class that ends with .php or .inc. And produce a new file mapping relationship, which is put into / vendor/composer/aotuload_classmap
4.files
{"aotuload": {"files": ["src/my/function.php"]}}
Manually specify the file to provide loading. Such as the global function file
The above is all the contents of the article "how to load composer automatically". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.