search
HomeDevelopment Toolscomposercomposer updates the specified dependency package method

composer updates the specified dependency package method

Mar 09, 2021 pm 01:56 PM
composerphprequireupdate

The following tutorial column of composer will introduce you to the method of composer updating the specified dependency package. I hope it will be helpful to friends in need!

composer updates the specified dependency package method

composer updates the require## of the specified dependency package

compoesr #/update can update the specified dependency package (upgrade/downgrade).

require is more flexible. If it is not installed, it will be installed. If it is installed, it will upgrade or downgrade according to the passed version number.
update cannot pass the specified version number on the command line. You need to manually edit composer.json first and specify the new version number. , and then execute the update command.

#忽略
composer require google/protobuf --ignore-platform-reqs -vvv
require command

Example

// 安装包
composer require hashids/hashids:2.0.0
// 已安装 升级
composer require hashids/hashids:3.0.0
// 已安装 降级
composer require hashids/hashids:2.0.4
update command

updatecommand Unable to specify package version on the command line No., you need to manually modify the composer.json file

// 安装包
composer require hashids/hashids:2.0.0
Incorrect usage

composer update hashids/hashids:3.0.0
Correct usage example

vim composer.json
"require": {
    "hashids/hashids": "3.0.0"
},
:wq
#升级到3.0.0
composer update hashids/hashids

vim composer.json
"require": {
    "hashids/hashids": "2.0.4"
},
:wq
#降级到2.0.4
composer update hashids/hashids
At the same time, if we edit and update If the version numbers of multiple packages are incorrect, you cannot use


composer update package1
composer update package2
composer update package3 method to update sequentially, because
composer will verify the integrity of the configuration file json vs lock, you specified that you want me to update A, but you B's version is inconsistent in json and lock, but you don't want me to update it. This is problematic.

At this time, you can only use

composer update to update dependencies globally. Note that it is an update operation for global packages. Some packages that you have not changed but use a version number range may also be updated and upgraded. Please Use with caution!

install command

install can be used to install dependencies for the first time after the project is initialized, and the version number in composer.lock will be read first , to ensure the consistency of package versions in collaborative development as much as possible. The package version record that exists in

composer.lock is equivalent to executing composer require packageName:versionNo, and the one that does not exist is equivalent to executing composer update packageName with versionRule in composer.json.

When we collaborate on development, A installs a new dependency package locally, or updates a dependency package, which will be written to

composer.lock/composer.json, and A uploads it to the warehouse. After B is pulled to the local, composer install should be executed once to synchronize the team's version changes.

So during collaborative development, we recommend uploading

composer.lock/composer.json to the remote warehouse at the same time.

Version number range

大于/大于等于:>1.2.3 >=1.2.3
小于/小于等于:=7.0",
    "ext-swoole": ">=4.0.0",
    "lib-curl": ">=7.29.0"
}

The above is the detailed content of composer updates the specified dependency package method. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:segmentfault. If there is any infringement, please contact admin@php.cn delete
What Defines a Composer: Understanding the RoleWhat Defines a Composer: Understanding the RoleMay 08, 2025 am 12:07 AM

Composers are people who express emotions, tell stories or express ideas by creating musical works, whose roles include conceiving musical structures, choosing instrument combinations, and working with other musicians. 1) Composers will go through four stages of conception, creation, modification and improvement during the creative process; 2) They need to master musical theories, such as harmony, counterpoint and melody, to ensure the quality and effect of the work.

Composer: Installing, Updating, and Managing DependenciesComposer: Installing, Updating, and Managing DependenciesMay 07, 2025 am 12:07 AM

Composer is a dependency management tool for PHP, and manages project dependencies through composer.json and composer.lock files. 1. Install Composer: Run a specific command and move composer.phar to the system path. 2. Update Composer: Use composelself-update command. 3. Dependency management: add dependencies through the composerrequire command, automatically update relevant files and download packages.

AI-Powered Composer: Code Generation and AnalysisAI-Powered Composer: Code Generation and AnalysisMay 06, 2025 am 12:11 AM

AI plays an important role in code generation and analysis: 1) generate code through machine learning and NLP, such as GitHub’s Copilot; 2) perform code analysis, identify bugs and optimization suggestions, such as SonarQube; 3) improve development efficiency and code quality, but requires manual review and optimization.

Composer: AI-Powered Tools and IntegrationsComposer: AI-Powered Tools and IntegrationsMay 05, 2025 am 12:11 AM

Composer itself does not include AI capabilities, but can be enhanced by AI tools. 1) AI can analyze composer.json files, and it is recommended to optimize dependencies and predict version conflicts. 2) AI-driven platforms such as GitHubCopilot can provide real-time code suggestions to improve development efficiency. When using AI tools, you need to verify and adjust them in combination with actual situations.

The Attributes of a Successful ComposerThe Attributes of a Successful ComposerMay 04, 2025 am 12:13 AM

The key traits of a successful composer include: 1) rich creativity and imagination, 2) solid mastery of technical skills and tools. These traits are similar to creative and structured thinking in programming, helping composers realize creativity and optimize their work in music creation.

The Requirements to Be a Composer: A Deep DiveThe Requirements to Be a Composer: A Deep DiveMay 03, 2025 am 12:08 AM

To become a composer, you need to master music theory, instrumental performance, be familiar with music style and history, and be creative and inspiring. Specific steps include: 1. Learn music theory, such as chord structure and rhythm mode; 2. Master the performance of musical instruments and improve creative inspiration; 3. Be familiar with music production software, such as AbletonLive, to improve creative efficiency; 4. Continuous practice and adjustment, create complex melodies and use discordant chords to increase music tension.

Composer: The Package Manager for PHP DevelopersComposer: The Package Manager for PHP DevelopersMay 02, 2025 am 12:23 AM

Composer is a dependency management tool for PHP, and manages project dependencies through composer.json file. 1) parse composer.json to obtain dependency information; 2) parse dependencies to form a dependency tree; 3) download and install dependencies from Packagist to the vendor directory; 4) generate composer.lock file to lock the dependency version to ensure team consistency and project maintainability.

The Integration of AI into Composer: Exploring PotentialThe Integration of AI into Composer: Exploring PotentialMay 01, 2025 am 12:02 AM

AI can show its strengths in the field of music creation. 1) AI generates music through machine learning and deep learning, enhancing diversity and innovation. 2) AI composers can assist composers and provide inspiration and creativity. 3) In actual applications, performance needs to be optimized to solve the problems of coherence and innovation in the generation of music.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.