In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 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 use Composer, I hope you will get something after reading this article. Let's discuss it together.
The use of Composer
1. Download the composer.phar file
From the project root, use cmd or bash to run the following command: (need to install PHP)
Php-r "readfile ('https://getcomposer.org/installer');" | php
two。 Initialize Composer
Use cmd or bash to run the following command, and after entering the appropriate information, complete the initialization of composer:
Composer init
A configuration file named composer.json is added to the root directory.
3. Add the class file written by yourself to the automatic loading of composer
Suppose some of the class files are in the folder. / app/db/, and the namespace db is defined. The following items should be added to the first curly braces in the composer.json file:
"autoload": {"psr-4": {"db\": "app/db/"}}
The entire composer.json file looks like this:
{"name": "linnzh/front", "type": "project", "license": "MIT", "authors": [{"name": "Linnzh", "email": "reg.lynnzh@gmail.com"}], "description": "some attempts on the front end", "require": {} "require-dev": {}, autoload: {"psr-4": {"db\": "db/"}
This key-value pair indicates that the composer loader loads the component as psr-4 and tells the loader that the class files in the app/db/ directory will be mapped to the namespace db.
4. Update configuration
After you modify the composer.json file, you must run the following command to generate the vendor/autoload.php file:
Composer install
A vender folder is generated under the root of the project and contains an autoload.php auto-load class file that can be imported directly when using a class file that is defined and configured in composer.json without having to use multiple require statements.
After reading this article, I believe you have a certain understanding of "how to use Composer". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!
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.