PHP Класс Consolidation\Cgr\Application

Показать файл Открыть проект

Защищенные свойства (Protected)

Свойство Тип Описание
$outputFile

Открытые методы

Метод Описание
buildConfigCommand ( string $execPath, array $composerArgs, string $key, string $value, array $env, string $installLocation ) : CommandToExec Generate command string to call composer config KEY VALUE to install one project.
buildGlobalCommand ( $composerCommand, $execPath, array $composerArgs, string $projectWithVersion, array $env, string $installLocation ) : CommandToExec Generate command string to call composer COMMAND to install one project.
configureProjectStability ( string $execPath, array $composerArgs, array $projects, array $options ) : array If --stability VALUE is provided, then run a composer config minimum-stability VALUE command to configure composer.json appropriately.
flipProjectsArray ( string[] $projects ) : array Convert from an array of projects to an array where the key is the project name, and the value (version) is an empty string.
generalCommand ( string $composerCommand, string $execPath, array $composerArgs, array $projects, array $options ) : array General command handler.
getCommandsToExec ( $command, array $composerArgs, array $projects, array $options ) : CommandToExec Return an array containing a list of commands to execute. Depending on the composition of the aguments and projects parameters, this list will contain either a single command string to call through to composer (if cgr is being used as a composer alias), or it will contain a list of appropriate replacement 'composer global require' commands that install each project in its own installation directory, while installing each projects' binaries in the global Composer bin directory, ~/.composer/vendor/bin.
getDefaultOptionValues ( string $home ) : array Return our list of default option values, with paths relative to the provided home directory.
isComposerVersion ( string $arg ) : boolean Identify an argument that could be a Composer version string.
parseArgvAndGetCommandList ( $argv, $home ) Figure out everything we're going to do, but don't do any of it yet, just return the command objects to run.
parseOutOurOptions ( array $argv, array $optionDefaultValues ) : array We use our own special-purpose argv parser. The options that apply to this tool are identified by a simple associative array, where the key is the option name, and the value is its default value.
projectWithVersion ( string $project, string $version ) : string Return $project:$version, or just $project if there is no $version.
requireCommand ( string $execPath, array $composerArgs, array $projects, array $options ) : array Provide a safer version of composer global require. Each project listed in $projects will be installed into its own project directory.
run ( array $argv, string $home ) : integer Run the cgr tool, a safer alternative to composer global require.
runCommandList ( array $commandList, $options ) : integer Run all of the commands in a list. Abort early if any fail.
separateProjectAndGetCommandList ( $argv, $home, $options ) Figure out everything we're going to do, but don't do any of it yet, just return the command objects to run.
separateProjectsFromArgs ( array $argv, $options ) : array After our options are removed by parseOutOurOptions, those items remaining in $argv will be separated into a list of projects and versions, and anything else that is not a project:version. Returns an array of two items containing: - An associative array, where the key is the project name and the value is the version (or an empty string, if no version was specified) - The remaining $argv items not used to build the projects array.
setOutputFile ( $outputFile ) Set up output redirection. Used by tests.
updateCommand ( $execPath, array $composerArgs, array $projects, array $options ) : array Run composer global update. Not only do we want to update the "global" Composer project, we also want to update all of the "isolated" projects installed via cgr in ~/.composer/global.

Защищенные методы

Метод Описание
overlayEnvironmentValues ( $defaults ) Replace option default values with the corresponding environment variable value, if it is set.

Описание методов

buildConfigCommand() публичный Метод

Generate command string to call composer config KEY VALUE to install one project.
public buildConfigCommand ( string $execPath, array $composerArgs, string $key, string $value, array $env, string $installLocation ) : CommandToExec
$execPath string The path to composer
$composerArgs array The arguments to pass to composer
$key string The config item to set
$value string The value to set the config item to
$env array Environment to set prior to exec
$installLocation string Location to install the project
Результат CommandToExec

buildGlobalCommand() публичный Метод

Generate command string to call composer COMMAND to install one project.
public buildGlobalCommand ( $composerCommand, $execPath, array $composerArgs, string $projectWithVersion, array $env, string $installLocation ) : CommandToExec
$composerArgs array The arguments to pass to composer
$projectWithVersion string The project:version to install
$env array Environment to set prior to exec
$installLocation string Location to install the project
Результат CommandToExec

configureProjectStability() публичный Метод

If --stability VALUE is provided, then run a composer config minimum-stability VALUE command to configure composer.json appropriately.
public configureProjectStability ( string $execPath, array $composerArgs, array $projects, array $options ) : array
$execPath string The path to composer
$composerArgs array Anything from the global $argv to be passed on to Composer
$projects array A list of projects to install, with the key specifying the project name, and the value specifying its version.
$options array User options from the command line; see $optionDefaultValues in the main() function.
Результат array

flipProjectsArray() публичный Метод

Convert from an array of projects to an array where the key is the project name, and the value (version) is an empty string.
public flipProjectsArray ( string[] $projects ) : array
$projects string[]
Результат array

generalCommand() публичный Метод

General command handler.
public generalCommand ( string $composerCommand, string $execPath, array $composerArgs, array $projects, array $options ) : array
$composerCommand string The composer command to run e.g. require
$execPath string The path to composer
$composerArgs array Anything from the global $argv to be passed on to Composer
$projects array A list of projects to install, with the key specifying the project name, and the value specifying its version.
$options array User options from the command line; see $optionDefaultValues in the main() function.
Результат array

getCommandsToExec() публичный Метод

Return an array containing a list of commands to execute. Depending on the composition of the aguments and projects parameters, this list will contain either a single command string to call through to composer (if cgr is being used as a composer alias), or it will contain a list of appropriate replacement 'composer global require' commands that install each project in its own installation directory, while installing each projects' binaries in the global Composer bin directory, ~/.composer/vendor/bin.
public getCommandsToExec ( $command, array $composerArgs, array $projects, array $options ) : CommandToExec
$composerArgs array
$projects array
$options array
Результат CommandToExec

getDefaultOptionValues() публичный Метод

Return our list of default option values, with paths relative to the provided home directory.
public getDefaultOptionValues ( string $home ) : array
$home string The user's home directory
Результат array

isComposerVersion() публичный Метод

Identify an argument that could be a Composer version string.
public isComposerVersion ( string $arg ) : boolean
$arg string The argument to test
Результат boolean

overlayEnvironmentValues() защищенный Метод

Replace option default values with the corresponding environment variable value, if it is set.
protected overlayEnvironmentValues ( $defaults )

parseArgvAndGetCommandList() публичный Метод

Figure out everything we're going to do, but don't do any of it yet, just return the command objects to run.
public parseArgvAndGetCommandList ( $argv, $home )

parseOutOurOptions() публичный Метод

The result of this function is an array of two items containing: - An array of the items in $argv not used to set an option value - An array of options containing the user-specified or default values
public parseOutOurOptions ( array $argv, array $optionDefaultValues ) : array
$argv array The global $argv passed in by php
$optionDefaultValues array An associative array
Результат array

projectWithVersion() публичный Метод

Return $project:$version, or just $project if there is no $version.
public projectWithVersion ( string $project, string $version ) : string
$project string The project to install
$version string The version desired
Результат string

requireCommand() публичный Метод

The binaries from each project will still be placed in the global composer bin directory.
public requireCommand ( string $execPath, array $composerArgs, array $projects, array $options ) : array
$execPath string The path to composer
$composerArgs array Anything from the global $argv to be passed on to Composer
$projects array A list of projects to install, with the key specifying the project name, and the value specifying its version.
$options array User options from the command line; see $optionDefaultValues in the main() function.
Результат array

run() публичный Метод

Run the cgr tool, a safer alternative to composer global require.
public run ( array $argv, string $home ) : integer
$argv array The global $argv array passed in by PHP
$home string The path to the user's home directory
Результат integer

runCommandList() публичный Метод

Run all of the commands in a list. Abort early if any fail.
public runCommandList ( array $commandList, $options ) : integer
$commandList array An array of CommandToExec
Результат integer

separateProjectAndGetCommandList() публичный Метод

Figure out everything we're going to do, but don't do any of it yet, just return the command objects to run.
public separateProjectAndGetCommandList ( $argv, $home, $options )

separateProjectsFromArgs() публичный Метод

After our options are removed by parseOutOurOptions, those items remaining in $argv will be separated into a list of projects and versions, and anything else that is not a project:version. Returns an array of two items containing: - An associative array, where the key is the project name and the value is the version (or an empty string, if no version was specified) - The remaining $argv items not used to build the projects array.
public separateProjectsFromArgs ( array $argv, $options ) : array
$argv array The $argv array from parseOutOurOptions()
Результат array

setOutputFile() публичный Метод

Set up output redirection. Used by tests.
public setOutputFile ( $outputFile )

updateCommand() публичный Метод

Run composer global update. Not only do we want to update the "global" Composer project, we also want to update all of the "isolated" projects installed via cgr in ~/.composer/global.
public updateCommand ( $execPath, array $composerArgs, array $projects, array $options ) : array
$composerArgs array Anything from the global $argv to be passed on to Composer
$projects array A list of projects to update.
$options array User options from the command line; see $optionDefaultValues in the main() function.
Результат array

Описание свойств

$outputFile защищенное свойство

protected $outputFile