adachsoft/composer-editor
Composer 安装命令:
composer require adachsoft/composer-editor
包简介
composer-editor
README 文档
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
统计信息
- 总下载量: 8
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-05-24