class Composer (View source)

Properties

protected Filesystem $files

The filesystem instance.

protected string|null $workingPath

The working path to regenerate from.

Methods

void
__construct(Filesystem $files, string|null $workingPath = null)

Create a new Composer manager instance.

bool
hasPackage(string $package)

Determine if the given Composer package is installed.

bool
requirePackages(array $packages, bool $dev = false, OutputInterface|null $output = null, string|null $composerBinary = null)

Install the given Composer packages into the application.

bool
removePackages(array $packages, bool $dev = false, OutputInterface|null $output = null, string|null $composerBinary = null)

Remove the given Composer packages from the application.

void
modify(callable $callback)

Modify the "composer.json" file contents using the given callback.

int
dumpAutoloads(string|array $extra = '', string|null $composerBinary = null)

Regenerate the Composer autoloader files.

int
dumpOptimized(string|null $composerBinary = null)

Regenerate the optimized Composer autoloader files.

array
findComposer(string|null $composerBinary = null)

Get the Composer binary / command for the environment.

string
findComposerFile()

Get the path to the "composer.json" file.

string
phpBinary()

Get the PHP binary.

Process
getProcess(array $command, array $env = [])

Get a new Symfony process instance.

$this
setWorkingPath(string $path)

Set the working path used by the class.

string|null
getVersion()

Get the version of Composer.

Details

void __construct(Filesystem $files, string|null $workingPath = null)

Create a new Composer manager instance.

Parameters

Filesystem $files
string|null $workingPath

Return Value

void

bool hasPackage(string $package)

Determine if the given Composer package is installed.

Parameters

string $package

Return Value

bool

Exceptions

RuntimeException

bool requirePackages(array $packages, bool $dev = false, OutputInterface|null $output = null, string|null $composerBinary = null)

Install the given Composer packages into the application.

Parameters

array $packages
bool $dev
OutputInterface|null $output
string|null $composerBinary

Return Value

bool

bool removePackages(array $packages, bool $dev = false, OutputInterface|null $output = null, string|null $composerBinary = null)

Remove the given Composer packages from the application.

Parameters

array $packages
bool $dev
OutputInterface|null $output
string|null $composerBinary

Return Value

bool

void modify(callable $callback)

Modify the "composer.json" file contents using the given callback.

Parameters

callable $callback

Return Value

void

Exceptions

RuntimeException

int dumpAutoloads(string|array $extra = '', string|null $composerBinary = null)

Regenerate the Composer autoloader files.

Parameters

string|array $extra
string|null $composerBinary

Return Value

int

int dumpOptimized(string|null $composerBinary = null)

Regenerate the optimized Composer autoloader files.

Parameters

string|null $composerBinary

Return Value

int

array findComposer(string|null $composerBinary = null)

Get the Composer binary / command for the environment.

Parameters

string|null $composerBinary

Return Value

array

protected string findComposerFile()

Get the path to the "composer.json" file.

Return Value

string

Exceptions

RuntimeException

protected string phpBinary()

Get the PHP binary.

Return Value

string

protected Process getProcess(array $command, array $env = [])

Get a new Symfony process instance.

Parameters

array $command
array $env

Return Value

Process

$this setWorkingPath(string $path)

Set the working path used by the class.

Parameters

string $path

Return Value

$this

string|null getVersion()

Get the version of Composer.

Return Value

string|null