Skip to main content

Glossary L

Glossary · E-commerce

Lock file

Area
E-commerce

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 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 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 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 against known security advisories. 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.

Sources

  1. Composer Documentation: Basic usage (opens in a new tab)

    Composer (getcomposer.org) accessed

  2. Composer Documentation: Libraries (opens in a new tab)

    Composer (getcomposer.org) accessed

Share on LinkedIn

Let's talk about your project.

If this term is on your desk right now, a conversation usually helps faster than any definition.

Search the website

Popular topics

All results