eta-orionis / composer-json-manipulator
Package to load, merge and save composer.json file(s). Cleaned up from symplify/composer-json-manipulator
1.0.1
2023-04-07 18:09 UTC
Requires
- php: >=8
Requires (Dev)
- phpunit/phpunit: ^9
This package is not auto-updated.
Last update: 2024-12-15 00:12:37 UTC
README
- load
composer.json
as an object - manipulate using fluent API
- save it back to a
composer.json
file
Install
composer require eta-orionis/composer-json-manipulator
Usage
namespace App; use EtaOrionis\ComposerJsonManipulator\ComposerJson; class SomeClass { public function run(): void { $composerJson = ComposerJson::fromFile(getcwd() . '/composer.json'); // Add a PSR-4 namespace $autoLoad = $composerJson->getAutoload(); $autoLoad['psr-4']['Cool\\Stuff\\'] = './lib/'; $composerJson ->setAutoload($autoLoad) ->save(getcwd() . '/composer.json'); } }