Composer API
Class

Composer\Package\Locker

class Locker

Reads/writes project lockfile (composer.lock).

Methods

__construct(IOInterface $io, JsonFile $lockFile, RepositoryManager $repositoryManager, InstallationManager $installationManager, string $composerFileContents)

Initializes packages locker.

static string getContentHash(string $composerFileContents)

Returns the md5 hash of the sorted content of the composer file.

bool isLocked()

Checks whether locker were been locked (lockfile found).

bool isFresh()

Checks whether the lock file is still up to date with the current hash

RepositoryInterface getLockedRepository(bool $withDevReqs = false)

Searches and returns an array of locked packages, retrieved from registered repositories.

Link[] getPlatformRequirements(bool $withDevReqs = false)

Returns the platform requirements stored in the lock file

getMinimumStability()

getStabilityFlags()

getPreferStable()

getPreferLowest()

getPlatformOverrides()

getAliases()

getLockData()

bool setLockData(array $packages, mixed $devPackages, array $platformReqs, mixed $platformDevReqs, array $aliases, string $minimumStability, array $stabilityFlags, bool $preferStable, bool $preferLowest, array $platformOverrides)

Locks provided data into lockfile.

Details

at line 53
public __construct(IOInterface $io, JsonFile $lockFile, RepositoryManager $repositoryManager, InstallationManager $installationManager, string $composerFileContents)

Initializes packages locker.

Parameters

IOInterface $io
JsonFile $lockFile lockfile loader
RepositoryManager $repositoryManager repository manager instance
InstallationManager $installationManager installation manager instance
string $composerFileContents The contents of the composer file

at line 72
static public string getContentHash(string $composerFileContents)

Returns the md5 hash of the sorted content of the composer file.

Parameters

string $composerFileContents The contents of the composer file.

Return Value

string

at line 109
public bool isLocked()

Checks whether locker were been locked (lockfile found).

Return Value

bool

at line 125
public bool isFresh()

Checks whether the lock file is still up to date with the current hash

Return Value

bool

at line 150
public RepositoryInterface getLockedRepository(bool $withDevReqs = false)

Searches and returns an array of locked packages, retrieved from registered repositories.

Parameters

bool $withDevReqs true to retrieve the locked dev packages

Return Value

RepositoryInterface

Exceptions

RuntimeException

at line 185
public Link[] getPlatformRequirements(bool $withDevReqs = false)

Returns the platform requirements stored in the lock file

Parameters

bool $withDevReqs if true, the platform requirements from the require-dev block are also returned

Return Value

Link[]

at line 213
public getMinimumStability()

at line 220
public getStabilityFlags()

at line 227
public getPreferStable()

at line 236
public getPreferLowest()

at line 245
public getPlatformOverrides()

at line 252
public getAliases()

at line 259
public getLockData()

at line 288
public bool setLockData(array $packages, mixed $devPackages, array $platformReqs, mixed $platformDevReqs, array $aliases, string $minimumStability, array $stabilityFlags, bool $preferStable, bool $preferLowest, array $platformOverrides)

Locks provided data into lockfile.

Parameters

array $packages array of packages
mixed $devPackages array of dev packages or null if installed without --dev
array $platformReqs array of package name => constraint for required platform packages
mixed $platformDevReqs array of package name => constraint for dev-required platform packages
array $aliases array of aliases
string $minimumStability
array $stabilityFlags
bool $preferStable
bool $preferLowest
array $platformOverrides

Return Value

bool