ability / composer-reader
A simple composer.json file reader
1.0.1
2024-08-04 19:01 UTC
Requires
- php: >=8.1
Requires (Dev)
- symfony/var-dumper: ^7.0
README
# Composer Reader A simple `composer.json` file reader. ## Installation You can install the package via Composer: ```bash composer require ability/composer-reader
Usage
Basic Usage
To read and parse a composer.json
file, you can use the Reader
class:
use Ability\ComposerReader\Reader; $context = Reader::create('/path/to/composer.json');
Accessing Data
The Context
class provides methods to access the data:
use Ability\ComposerReader\Context; // Get a value by key $value = $context->get('name'); // Check if a key exists $exists = $context->has('require.php');
Array Access
The Context
class implements ArrayAccess
, so you can use it like an array:
// Get a value by key $value = $context['name']; // Check if a key exists $exists = isset($context['require.php']);
JSON Serialization
The Context
class implements JsonSerializable
, so you can easily convert it to JSON:
$json = json_encode($context);
Requirements
- PHP >= 8.0
Development
To contribute to this project, you can install the development dependencies:
composer install
License
The MIT License (MIT). Please see License File for more information.
Authors
- Roman Zhakhov roman.zhakhov@thomsonreuters.com