/composer-parser

A parser that can parse all the installed PHP packages composer.json file in your project

Primary LanguagePHPMIT LicenseMIT

ComposerParser

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.

Test Status Total Downloads packagist License

Installation

Require this package with composer:

composer require xdevor/composer-parser

Features

  • 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

Usage

  1. 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
  1. 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

Contributing

Please see CONTRIBUTING for details.

Code of Conduct

In order to ensure that the php community is welcoming to all, please review and abide by the Code of Conduct.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

License

ComposerParser is open-sourced software licensed under the MIT license.