In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the role of the composer.lock file, the article is very detailed, has a certain reference value, interested friends must read it!
Basic use of Composer
Using composer.json in a project
To use composer in a project, you need to have a composer.json file, which is mainly used to declare the relationship between packages and other element tags.
Require keyword
The first thing to do in composer.json is to use the require keyword. You will tell composer which packages are needed for your project.
The code is as follows:
{"require": {"monolog/monolog": "1.0.*"}}
As you can see, the object of require will map the package name (monolog/monolog) and the version of the package is 1.0.*
Naming of the package
Basically, the name of the package is the principal name / project name (monolog/monolog), which must be unique, but the name of the project, that is, our package, can have the same name, such as: igorw/json, and seldaek/json
The version of the package
We need to use the version 1.0.99 of monolog, which means that as long as the version is 1.0 branch, such as 1.0.0, 1.0.2 or 1.0.99.
There are two ways to define a version:
1. Standard version: defines a guaranteed version package file, such as 1.0.2
two。 Range of versions: use comparison symbols to define the range of valid versions. Valid symbols are >, > =, addWarning ('Foo').
Of course, you can load your own code in composer.json:
The code is as follows:
{"autoload": {"psr-0": {"Acme": "src/"}
Composer will register psr-0 as the namespace of Acme
You can define a mapping to the file directory through the namespace. The src directory is your root directory, and vendor is the same level directory. For example, a file: src/Acme/Foo.php contains the Acme\ Foo class.
When you add autoload, you have to re-install to generate the vendor/autoload.php file
When we reference this file, we will return the strength of an autoloader class, so you can put the returned value into a variable and then add more namespaces, which is very convenient in a development environment, such as:
The code is as follows:
$loader = require 'vendor/autoload.php';$loader- > add (' Acme\ Test', _ _ DIR__)
The role of composer.lock files
The install command reads the composer.json file from the current directory, handles the dependencies, and installs it into the vendor directory.
The code is as follows:
Composer install
If a composer.lock file exists in the current directory, it reads the dependent version from this file instead of getting the dependency based on the composer.json file. This ensures that every user of the library gets the same dependent version.
If there is no composer.lock file, composer will create it after processing the dependency.
To get the latest version of the dependency and to upgrade the composer.lock file, you should use the update command.
The code is as follows:
Composer update
This will resolve all dependencies of the project and write the exact version number to composer.lock.
If you just want to update a few packages, you can list them separately like this:
The code is as follows:
Composer update vendor/package vendor/package2
You can also use wildcards for batch updates:
The code is as follows:
Composer update vendor/* above is all the contents of the article "what are the functions of composer.lock files?" Thank you for your reading! Hope to share the content to help you, more related 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.