This library provides a set of utility functions designed to help you parse your project's Composer configuration, and those of its dependencies, at runtime.
The API combines functional and object-oriented approaches.
(Chicken and egg...)
$absoluteVendorPath = Composed\VENDOR_DIR;
$absoluteProjectPath = Composed\BASE_DIR;
You can fetch data from the composer.json
file of a specific package.
$authors = Composed\package_config('phpunit/phpunit', 'authors');
assert($authors === [
[
'name' => "Sebastian Bergmann",
'email' => "sebastian@phpunit.de",
'role' => "lead",
],
]);
You can fetch data from all composer.json
files in your project in one go.
$licenses = Composed\package_configs('license');
assert($licenses === [
'joshdifabio/composed' => "MIT",
'doctrine/instantiator' => "MIT",
'phpunit/php-code-coverage' => "BSD-3-Clause",
]);
$path = Composed\package('phpunit/phpunit')->getPath('composer.json');
foreach (Composed\packages() as $packageName => $package) {
$pathToPackageConfig = $package->getPath('composer.json');
// ...
}
You can also fetch data from the composer.json
file located in your project root.
$projectAuthors = Composed\project_config('authors');
assert($projectAuthors === [
[
'name' => 'Josh Di Fabio',
'email' => 'joshdifabio@somewhere.com',
],
]);
Install Composed using composer.
composer require joshdifabio/composed
Credit goes to @igorw whose get-in library is partially copied into this library. Unfortunately, igorw/get-in
requires PHP 5.4 while Composed aims for PHP 5.3 compatibility.
Composed is released under the MIT license.