search
HomeDevelopment ToolscomposerRecommend six little-known Composer commands

Recommend six little-known Composer commands

Composer is a dependency management tool for PHP. If you are a PHP developer, then you probably use it every day and frequently run the commands require, install and update. Maybe you didn't realize it, but we can use some other Composer commands to make it easier to use.

There are many commands you can use, but today I will share 6 commands that I use and that help me every day.

show

Let’s talk about the show command first. It allows you to view all installed packages for your project (including dependencies), as well as view descriptions of related packages. All this information can be found in the Composer lock file (composer.lock), but using the show command is a relatively simpler and more convenient way to view package information.

To list all installed packages with their version numbers and descriptions, just use show:

composer show

Sometimes this information is presented in the form of a dependency tree It will be easier to understand if you view it. You can pass --tree or -t Parameters:

composer show -t

If you want to filter the returned packages, you can use wildcards to pass an extra character String parameters *:

composer show 'symfony/*'

This will return all installed symfony packages. Pay attention to the quotation marks here. If you are using the bash shell, you do not need to add these quotation marks, but if you are using zsh and you do not need the quotation marks, a ‘no matches found’ error will be reported.

If you want to see information about a specific package, the full package name is required:

composer show laravel/framework

This will show you the version installed, its license and dependencies, and where it is installed locally and other information.

why

If you want to know why a specific package is installed, you can use the why command to determine which dependencies require it:

composer why vlucas/phpdotenv

why why is an alias for the depends command, but personally I find it easier to remember using 'why'. You can view this information in a dependency tree using the --tree or -t flag:

composer why vlucas/phpdotenv -t

why-not

Sometimes, one or Multiple installed packages will prevent the package from being installed or updated. In order to check which installation packages we can use the why-not command (alias prohibits). For example, Laravel recently released a new 5.8 version of the framework; we can use the why-not command to check for any packages that are preventing us from updating the laravel/framework package:

composer why-not laravel/framework 5.8

Similarly, we can view this information in the dependency tree using the --tree or -t tags:

composer why-not laravel/framework 5.8 -t

outdated

at Before using the composer update command, you may want to check the installed packages to see which ones can be upgraded. This can be done using the outdated command.

composer outdated

This command is one of the aliases of composer show -lo.

According to the semantic version, color code is returned to indicate the status of each package:

  • Green: The current installation package is the latest version
  • Yellow: There are upgradeable updates, but there may be incompatible modifications.
  • Red: There are minor version upgrades available (usually bug fixes)

If you want to highlight minor upgrades, you can use outdated command, with --minor-only or -m Parameters:

composer outdated -m

Status

I find myself using # all the time ##install, update command parameters --prefer-source to handle source code installation dependencies. Then, if I modify any of these dependencies, I need a way to quickly check which packages have been modified. The status command provides a convenient method.

You can use the

--verbose or -v parameters to view locally modified packages and files:

composer status -v
I found that using the verbose tag is the most useful way to use this command.

License

Finally, it is very useful to know the license of each package you install. Composer has a convenient

licenses command for querying the complete list of licenses:

composer licenses

For more related composer tutorial articles, please visit the

composer usage tutorial column!

The above is the detailed content of Recommend six little-known Composer commands. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Composer: An Introduction to the PHP Dependency ManagerComposer: An Introduction to the PHP Dependency ManagerApr 21, 2025 am 12:02 AM

Composer is a dependency management tool for PHP, which is used to manage libraries and packages required by projects. 1) It defines dependencies through composer.json file, 2) installs and updates using command line tools, 3) automates the dependency management process, improves development efficiency, 4) supports advanced functions such as dynamically adding dependencies and automatic loading, 5) Ensures consistency of the team environment through composer.lock file.

The Purpose of Composer: Managing Dependencies EfficientlyThe Purpose of Composer: Managing Dependencies EfficientlyApr 20, 2025 am 12:04 AM

Composer is a dependency management tool for PHP, and manages project dependencies through composer.json and composer.lock files. 1. Create the composer.json file and run the composerinstall installation dependency. 2. Use composerrequire to add new dependencies. 3. Configure autoload to implement automatic loading of classes. 4. Use composerdiagnose to check the health status of the project. 5. Optimize dependency management: specify the package name update, use composerdump-autoload-o to optimize the autoloader, use composerinstall--no-d in the production environment

Composer and AI: New Possibilities in PHP DevelopmentComposer and AI: New Possibilities in PHP DevelopmentApr 19, 2025 am 12:03 AM

The combination of AI and Composer can improve PHP development efficiency and security. Specifically reflected in: 1. Dependency analysis and optimization: AI can predict dependencies and reduce conflicts. 2. Automated security checks: AI can identify security vulnerabilities, and it is recommended to update them. 3. Code generation and optimization: AI can automatically generate and optimize related code.

Using Dicr/Yii2-Google to integrate Google API in YII2Using Dicr/Yii2-Google to integrate Google API in YII2Apr 18, 2025 am 11:54 AM

VprocesserazrabotkiveB-enclosed, Мнепришлостольностьсясзадачейтерациигооглапидляпапакробоглесхетсigootrive. LEAVALLYSUMBALLANCEFRIABLANCEFAUMDOPTOMATIFICATION, ČtookazaLovnetakProsto, Kakaožidal.Posenesko

How to use Composer to resolve JSON Schema verification issuesHow to use Composer to resolve JSON Schema verification issuesApr 18, 2025 am 11:51 AM

I'm having a tricky problem when developing a Symfony-based application: how to effectively validate JSON data format. Initially, I tried using manual verification code, but this was not only complicated, but also error-prone. After some exploration, I discovered a Composer package called ptyhard/json-schema-bundle, which brought great convenience and efficiency to my project.

Use Composer to solve the dilemma of recommendation systems: andres-montanez/recommendations-bundleUse Composer to solve the dilemma of recommendation systems: andres-montanez/recommendations-bundleApr 18, 2025 am 11:48 AM

When developing an e-commerce website, I encountered a difficult problem: how to provide users with personalized product recommendations. Initially, I tried some simple recommendation algorithms, but the results were not ideal, and user satisfaction was also affected. In order to improve the accuracy and efficiency of the recommendation system, I decided to adopt a more professional solution. Finally, I installed andres-montanez/recommendations-bundle through Composer, which not only solved my problem, but also greatly improved the performance of the recommendation system. You can learn composer through the following address:

How to quickly build Fecmall advanced project templates using ComposerHow to quickly build Fecmall advanced project templates using ComposerApr 18, 2025 am 11:45 AM

When developing an e-commerce platform, it is crucial to choose the right framework and tools. Recently, when I was trying to build a feature-rich e-commerce website, I encountered a difficult problem: how to quickly build a scalable and fully functional e-commerce platform. I tried multiple solutions and ended up choosing Fecmall's advanced project template (fecmall/fbbcbase-app-advanced). By using Composer, this process becomes very simple and efficient. Composer can be learned through the following address: Learning address

Improve Doctrine entity serialization efficiency: application of sidus/doctrine-serializer-bundleImprove Doctrine entity serialization efficiency: application of sidus/doctrine-serializer-bundleApr 18, 2025 am 11:42 AM

I had a tough problem when working on a project with a large number of Doctrine entities: Every time the entity is serialized and deserialized, the performance becomes very inefficient, resulting in a significant increase in system response time. I've tried multiple optimization methods, but it doesn't work well. Fortunately, by using sidus/doctrine-serializer-bundle, I successfully solved this problem, significantly improving the performance of the project.

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

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.

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

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