Easily parse your project's Composer configuration, and those of its dependencies, at runtime.
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., (*2)
The API combines functional and object-oriented approaches., (*3)
(Chicken and egg...), (*4)
$absoluteVendorPath = Composed\VENDOR_DIR;
$absoluteProjectPath = Composed\BASE_DIR;
You can fetch data from the composer.json
file of a specific package., (*5)
$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., (*6)
$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., (*7)
$projectAuthors = Composed\project_config('authors'); assert($projectAuthors === [ [ 'name' => 'Josh Di Fabio', 'email' => 'joshdifabio@somewhere.com', ], ]);
Install Composed using composer., (*8)
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., (*9)
Composed is released under the MIT license., (*10)