Complete Guide to Viewing Installed Packages and Versions in Composer

Nov 22, 2025 · Programming · 10 views · 7.8

Keywords: Composer | Package Management | Version Viewing | PHP Dependencies | Development Tools

Abstract: This article provides a comprehensive guide on various methods to view installed packages and their versions in Composer, with detailed analysis of the composer show command usage and parameter options. Through practical case studies, it demonstrates how to quickly obtain package version information in local development environments, resolve dependency conflicts, and explores advanced usage and best practices of related commands.

Overview of Composer Package Management

As the most crucial dependency management tool in the PHP ecosystem, Composer's package version management capabilities are essential for project maintenance. In practical development, developers frequently need to quickly view all installed packages and their specific version information in the current environment, especially when dealing with dependency conflicts or environment migration.

Core Command Analysis

The most direct and effective method to view installed packages and their version information is using the composer show command. This command displays all installed packages and their version information in the current project by default. In earlier versions of Composer, composer show -i (short for --installed) could achieve the same result, but this option has been marked as deprecated in the latest versions.

The basic syntax of the command is as follows:

composer show

After executing this command, Composer outputs information in a format similar to:

symfony/symfony                      v2.1.0 The Symfony PHP framework
doctrine/orm                         v2.2.3 Doctrine ORM
twig/extensions                      v1.0.0 Common additional features for Twig

Global Package Management

For globally installed packages, use the composer global show command. This is particularly useful when managing tool packages shared across projects, such as code formatters, static analysis tools, etc.

Global package viewing command:

composer global show

Command Parameter Details

The composer show command supports various parameters to meet different viewing requirements:

Practical Application Scenarios

Consider a typical development scenario: A developer uses Symfony 2.1 for development in a local environment, and the project runs normally. When deploying the project to a server, dependency conflicts occur due to changes in package versions. At this point, the developer needs to quickly obtain accurate version information for all packages in the local environment.

By executing the composer show command, developers can:

  1. Obtain a complete list of all installed packages and their versions
  2. Identify package versions that may cause conflicts
  3. Reproduce the same dependency configuration in the server environment
  4. Generate accurate version constraints for composer.json

Output Format Customization

Composer provides flexible output to meet different needs. Use the --format parameter to specify the output format:

composer show --format=json

JSON format output facilitates script processing and automation tool integration, particularly suitable for version checks in CI/CD pipelines.

Version Comparison and Update Checking

To check which packages have available updates, use:

composer show -o

This command displays results with color coding: green indicates the package is at the latest version, yellow indicates backward-incompatible updates are available, and red indicates backward-compatible updates are available.

Detailed Package Information Viewing

For specific packages, more detailed information can be viewed:

composer show symfony/symfony

This displays complete package information, including description, keywords, license, homepage, source repository, etc.

Platform Package Management

Composer can also manage platform packages (PHP and its extensions):

composer show -p

This is particularly useful for verifying whether the server environment meets project requirements.

Best Practice Recommendations

In daily development, it is recommended to:

Common Problem Resolution

When encountering dependency conflicts, the composer show command combined with other Composer commands can provide complete solutions:

  1. Use composer show to obtain current versions
  2. Use composer depends to analyze dependency relationships
  3. Use composer why-not to identify conflict causes
  4. Adjust version constraints in composer.json

By mastering the composer show command and its related parameters, developers can more effectively manage project dependencies, ensure development environment consistency, and quickly resolve dependency conflict issues.

Copyright Notice: All rights in this article are reserved by the operators of DevGex. Reasonable sharing and citation are welcome; any reproduction, excerpting, or re-publication without prior permission is prohibited.