class Composer (View source)

The Composer class is a wrapper for setting up Composer and executing commands.

Properties

private $autoloader Composer autoloader within the temporary extraction directory.
private $composerVersion The Composer version to be used.
private $extractionDir Composer extraction directory within temporary directory.
private $installDirCacheFile A chached file including the temporary Composer install directory.
private $pharUrl The download URL for the composer.phar file.
private $reservedShutdownMemory A variable to reserve memory for running a shutdown function when Composer reaches the allowd memory limit.

Methods

__construct()

The constructor runs the setup.

setUp()

Set up Composer by downloading and extracting the composer.phar to a temporary directory outside the document root, defining some environment variables, registering a shutdown function and including the autoloader.

string
run(string $command, bool $getBuffer = false)

Run a given Composer command.

string
downloadPhar(string $dir)

Download the composer.phar file to a given directory.

string
getInstallDir()

Read the Composer install directory from cache to reuse the installation in case Composer was already used before. In case Composer hasn't been used before, a new path will be generated and save to the cache.

string
newInstallDir()

Generate a fresh installation directory for Composer.

shutdownOnError()

A shutdown function to handle memory limit erros.

Details

__construct()

The constructor runs the setup.

private setUp()

Set up Composer by downloading and extracting the composer.phar to a temporary directory outside the document root, defining some environment variables, registering a shutdown function and including the autoloader.

string run(string $command, bool $getBuffer = false)

Run a given Composer command.

Parameters

string $command
bool $getBuffer

Return Value

string The command output on false or in case $getBuffer is true

private string downloadPhar(string $dir)

Download the composer.phar file to a given directory.

Parameters

string $dir

Return Value

string The full path to the downloaded composer.phar file

private string getInstallDir()

Read the Composer install directory from cache to reuse the installation in case Composer was already used before. In case Composer hasn't been used before, a new path will be generated and save to the cache.

Return Value

string The path to the installation directory

private string newInstallDir()

Generate a fresh installation directory for Composer.

Return Value

string The path to the directory

private shutdownOnError()

A shutdown function to handle memory limit erros.