adachsoft / composer-editor
composer-editor
v0.1.0
2026-05-24 08:40 UTC
Requires
- php: ^8.3
- adachsoft/collection: ^3.0
- adachsoft/composer-json-fixer: ^0.5
Requires (Dev)
- adachsoft/php-code-style: ^0.5
- friendsofphp/php-cs-fixer: ^3.95
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^13.1
- rector/rector: ^2.4
- symplify/phpstan-rules: ^14.9
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 formattingadachsoft/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