fr3nch13/composer-lock-parser

OOP reader of composer.lock file.

1.0.0 2023-02-27 03:34 UTC

This package is auto-updated.

Last update: 2024-04-30 00:45:57 UTC


README

Coverage Total Downloads Latest Stable Version GitHub release

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