fr3nch13 / composer-lock-parser
OOP reader of composer.lock file.
1.0.0
2023-02-27 03:34 UTC
Requires
- php: ~7.4||~8.0
Requires (Dev)
- phpcompatibility/php-compatibility: ^9.3
- phpstan/phpstan: ^1.9
- phpunit/phpunit: ~9.0||~10.0
- staabm/annotate-pull-request-from-checkstyle: ^1.8
This package is auto-updated.
Last update: 2024-10-30 02:10:52 UTC
README
OOP reader of composer.lock file
This is a fork of the original project located at: https://github.com/t4web/ComposerLockParser
Introduction
Parse composer.lock
file and return full information about installed packages in OOP style.
Requirements
PHP >= 7.4
TODO
- Add more info to the
Package.php
with info from thecomposer.lock
Installation
composer.json:
"require": { "fr3nch13/composer-lock-parser": "~1.0" }
OR
composer require fr3nch13/composer-lock-parser
Usage
Creating ComposerInfo object and getting all of the packages
$composerInfo = new \ComposerLockParser\ComposerInfo('/path/to/composer.lock'); // default all packages $packages = $composerInfo->getPackages(); // or explicitly get all packages $packages = $composerInfo->getPackages($composerInfo::ALL); echo $packages[0]->getName(); echo $packages[0]->getVersion(); echo $packages[0]->getNamespace();
Getting just production packages.
$composerInfo = new \ComposerLockParser\ComposerInfo('/path/to/composer.lock'); $packages = $composerInfo->getPackages($composerInfo::PRODUCTION);
Getting just development packages.
$composerInfo = new \ComposerLockParser\ComposerInfo('/path/to/composer.lock'); $packages = $composerInfo->getPackages($composerInfo::DEVELOPMENT);
Testing
Tests runs with Phpunit, phpstan, and phpcs
I reccommend running composer ci
before committing your code and pushing it to github.
See the scripts
in composer.json
.
$ composer ci
$ composer test
$ composer cs-check
$ composer phpstan