adachsoft/composer-editor

composer-editor

Maintainers

Package info

gitlab.com/a.adach/composer-editor

Issues

pkg:composer/adachsoft/composer-editor

Statistics

Installs: 5

Dependents: 0

Suggesters: 0

Stars: 0

v0.1.0 2026-05-24 08:40 UTC

This package is not auto-updated.

Last update: 2026-05-25 05:00:56 UTC


README

A PHP library for programmatic reading and editing of composer.json files while preserving formatting and indentation. Provides a clean facade + builder pattern with integration to adachsoft/composer-json-fixer for robust JSON handling.

Requirements

  • PHP: 8.3 or higher
  • Dependencies:
    • adachsoft/composer-json-fixer - JSON parsing and formatting
    • adachsoft/collection - immutable collections
  • Development tools (configured via adachsoft/php-code-style):
    • PHPUnit
    • PHPStan
    • Rector
    • PHP-CS-Fixer

Installation

Install via Composer:

composer require adachsoft/composer-editor

Development tools are automatically configured through adachsoft/php-code-style.

Basic usage

use AdachSoft\ComposerEditor\PublicApi\ComposerEditorBuilder;

$builder = new ComposerEditorBuilder();

// Load existing composer.json
$editor = $builder->load('composer.json');

// Edit fields
$editor->setDescription('My awesome package');
$editor->addRequire('symfony/console', '^6.0');
$editor->addKeyword('php');

// Save changes
$editor->save();

// Create new composer.json from scratch
$dto = new CreateComposerJsonDto(
    'vendor/package',
    'Description goes here'
);
$newEditor = $builder->create('composer.json', $dto);
$newEditor->save();

Quality tools

Run quality checks using Composer scripts:

composer cs:check   # PHP-CS-Fixer (check)
composer cs:fix     # PHP-CS-Fixer (fix)
composer stan       # PHPStan analysis
composer rector     # Rector code style

License

MIT