ComposerParser is a PHP package that allows you to parse all the installed PHP packages composer.json file. If you have ever worked with PHP packages, you know how important composer.json is. It describes the package's dependencies, version constraints, and other metadata like providers of laravel app. However, parsing all of the composer.json files in a project can be a tedious and time-consuming task, especially if you are working with multiple packages.
With ComposerParser, you can easily extract information from all of the composer.json files in your project.
Require this package with composer:
composer require xdevor/composer-parser
- Supports parsing all installed PHP packages' composer.json files in your project
- Can easily extract specific information of nested composer.json files in your project
- parse specific installed package by key
...
use Xdevor\ComposerParser\Parser;
...
(new Parser())->parse('the/package', 'name'); // return name of the package
(new Parser())->parse('the/package', 'authors.0.name'); // return the first author name
(new Parser())->parse('the/package', 'not_exist_key'); // return null if key not exist
(new Parser())->parse('the/package', 'not_exist_key', 'default'); // return 'default' if key not exist
(new Parser(__DIR__ . '/customize/path/installed.json'))->parse('the/package', 'name'); // parse customize path
- parse all installed package by key
...
use Xdevor\ComposerParser\Parser;
...
(new Parser())->parseAll($key = 'name'); // return name of all installed PHP packages
(new Parser())->parseAll($key = 'extra.laravel.providers'); // return providers of all installed PHP packages
Please see CONTRIBUTING for details.
In order to ensure that the php community is welcoming to all, please review and abide by the Code of Conduct.
Please review our security policy on how to report security vulnerabilities.
ComposerParser is open-sourced software licensed under the MIT license.