PHP and Composer: what to check beyond the version number

Project requirements, composer.lock, and the actual PHP answer different questions. How to distinguish platform simulation from execution.

A transparent template and a module with an empty slot: a metaphor for the gap between requirements and the actual environment.
A transparent template and a module with an empty slot: a metaphor for the gap between requirements and the actual environment.

Requirements, locked dependencies, and the actual environment answer different questions.

The application installs and opens on a development machine. After moving to another machine, it may stop before reaching the required scenario. The PHP version looks suitable, but an extension is missing, a different configuration is in use, or the dependency set differs from the one that was checked.

This transition requires looking at three separate things: application requirements, locked packages, and the actual runtime environment. Each has its own source. Success at one level does not establish that the others are correct.

A requirement describes an acceptable environment

A project may define a minimum PHP version and required extensions. These are runtime requirements. They do not tell us which interpreter actually handles a web request on the server.

For example, the dependency definitions of Article's editorial and public applications require PHP 8.5 or later. The declaration itself does not confirm that this version is installed on every machine or that all required extensions are present.

Extensions need to be considered by their purpose. One is needed for database access, another for images or international text. A hypothetical server may meet the version requirement while lacking the image processing capability without which a particular scenario cannot run.

Locked packages define a specific set

Dependency definitions set allowed constraints, while composer.lock records the selected versions. With a consistent lock file, composer install installs that set. composer update resolves dependencies again and may change it. The Composer documentation explains this distinction.

Reproducing a checked application and selecting new dependencies are therefore different tasks. When the move itself is being investigated, an unnoticed package update adds another variable.

Suppose two machines have the same code but different locked packages. An error on the second machine may concern a different application composition. Before looking for the cause, we should establish which set is actually being compared.

The target platform may be simulated

The config.platform setting supplies target PHP and extension versions for package selection. It influences dependency resolution but does not install an interpreter or extensions on the machine.

Successful package selection against a simulated target therefore needs a separate comparison with actual execution.

Installed packages have a separate check that does not update them:

composer check-platform-reqs

According to the command documentation, it checks the actual PHP and extensions, ignoring config.platform. The result applies to the environment in which Composer runs.

The console and the web process may differ

Console PHP and the PHP serving web requests are different ways of running the interpreter. Their configuration and available extensions may differ. PHP supports separate configuration files for different SAPIs and documents differences in console execution. A console check alone does not show the entire state of the web process.

It is therefore important to know exactly which interpreter runs in each role. A background consumer needs its own environment checked; a page needs the web runtime checked. Publishing the full configuration on an open page is not a prerequisite for this investigation.

QuestionAppropriate subject of the check
Which version is allowed?Project and package requirements
Which packages were selected?The locked dependency set
What is available to a command?The actual console PHP and extensions
What handles a web request?The defined web process and its configuration

Installation can also execute code

Composer supports root project scripts. Dependencies' own scripts do not run as additional root package scripts. Plugins have a separate execution mechanism and need a defined policy for allowing them.

Installation should therefore be treated as an operation with known sources and behavior. Disabling scripts or plugins also changes the preparation result: required project steps may remain incomplete. The policy is determined for the specific composition, rather than by an arbitrary command.

Compatibility does not complete the move

Matching PHP and package requirements does not establish correct migrations, permissions, caching, or user scenarios. These tasks need their own checks.

Before a move, it helps to record a specific application composition and then compare it with the actual execution processes. This keeps one difference from hiding another.

  1. Conformance How one fix to a shared foundation reaches sites
  2. Observability When a server is truly ready to launch
  3. Platform Engineering PHP runtime: extensions, owned INI and OPcache in FPM
  4. Platform Engineering First Symfony site on a prepared stack: Composer and file permissions
  5. PHP PHP extensions on E-01: separate sets for CLI and FPM

A project by the author · Weather Solution200

After reading, a look outside.

Temperature, rain and wind in your city. Check the forecast and plan the hours ahead.

Check the forecast
Next article