A lock file records the exact versions of all packages installed in a project, so that every installation ends up in the same state; with Composer it is composer.lock.
While composer.json
Composer
Composer is a tool for dependency management in PHP: a project declares the libraries it depends on, and Composer installs and updates them. Read in the glossary → sets out which package versions a project allows, the lock file records the versions that were actually chosen. Running composer update resolves suitable versions for every dependency
Dependency
A dependency is a third-party software package that a project builds on and needs in order to run; packages required by a dependency count as dependencies too. Read in the glossary → in composer.json. The command then writes each package and its exact version to composer.lock, locking the project to those versions. Once a lock file exists, composer install uses exactly those versions. Newer versions come in only with an explicit update.
The Composer documentation on basic usage recommends committing composer.lock to version control. The CI server, the production machines and the other developers on the team then all use the same dependency versions. A tip in the same documentation suggests keeping the vendor directory, with all its third-party code, out of version control.
The current documentation recommends committing the lock file for libraries too, that is, packages that other projects use. Among other things, this can help stop supply chain attacks Supply chain attack A supply chain attack is a cyber attack in which attackers first compromise a supplier, such as a provider of software or components, in order to reach the actual target through it. Read in the glossary → from spreading. A library's lock file, however, has no effect on the projects that use that library.
We check the lock file that ships with Shopware 5 Shopware Shopware is e-commerce software from shopware AG in Schöppingen, Germany; the vendor says its current product, Shopware 6, is a complete redevelopment of Shopware 5. Read in the glossary → against known security advisories Security advisory A security advisory is a published notice about a vulnerability in a software component that names the affected versions and, where available, the first fixed version. Read in the glossary → . For the dependencies we have updated, we keep a lock file of our own. It belongs to our own Composer manifest, the separate file that sits beside the shipped composer.json.
See also
-
Composer
Composer is a tool for dependency management in PHP: a project declares the libraries it depends on, and Composer installs and updates them.
E-commerce
-
Dependency
A dependency is a third-party software package that a project builds on and needs in order to run; packages required by a dependency count as dependencies too.
E-commerce
-
Repository
A repository (on GitHub, for example) holds a software project with all its files, its documentation and the revision history of every file.
E-commerce
Sources
-
Composer Documentation: Basic usage (opens in a new tab)
Composer (getcomposer.org) accessed
-
Composer Documentation: Libraries (opens in a new tab)
Composer (getcomposer.org) accessed