PHP code example of xdevor / composer-parser

1. Go to this page and download the library: Download xdevor/composer-parser library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

xdevor / composer-parser example snippets


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

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