symplify / composer-json-manipulator
This package is abandoned and no longer maintained.
No replacement package was suggested.
Package to load, merge and save composer.json file(s)
Package info
github.com/deprecated-packages/composer-json-manipulator
pkg:composer/symplify/composer-json-manipulator
11.1.18
2022-12-16 14:04 UTC
Requires
- php: >=8.1
- nette/utils: ^3.2
- symfony/config: ^6.2
- symfony/dependency-injection: 6.1.*
- symfony/filesystem: ^6.2
- symplify/package-builder: ^11.1.18
- symplify/smart-file-system: ^11.1.18
- symplify/symplify-kernel: ^11.1.18
Requires (Dev)
- phpunit/phpunit: ^9.5.26
Conflicts
- symplify/autowire-array-parameter: <11.1.18
- symplify/coding-standard: <11.1.18
- symplify/config-transformer: <11.1.18
- symplify/easy-ci: <11.1.18
- symplify/easy-coding-standard: <11.1.18
- symplify/easy-parallel: <11.1.18
- symplify/easy-testing: <11.1.18
- symplify/monorepo-builder: <11.1.18
- symplify/php-config-printer: <11.1.18
- symplify/phpstan-extensions: <11.1.18
- symplify/phpstan-rules: <11.1.18
- symplify/rule-doc-generator: <11.1.18
- symplify/rule-doc-generator-contracts: <11.1.18
- symplify/symfony-static-dumper: <11.1.18
- symplify/symplify-kernel: <9.4.70
- symplify/vendor-patches: <11.1.18
This package is auto-updated.
Last update: 2022-12-17 14:47:43 UTC
README
- load to
composer.jsonto an object - use handful methods
- merge it with others
- print it back to
composer.jsonin human-like format
Install
composer require symplify/composer-json-manipulator
Add to your config/config.php:
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonManipulatorConfig; return static function (ContainerConfigurator $containerConfigurator): void { $containerConfigurator->import(ComposerJsonManipulatorConfig::FILE_PATH); };
Usage
namespace App; use Symplify\ComposerJsonManipulator\ComposerJsonFactory; class SomeClass { /** * @var ComposerJsonFactory */ private $composerJsonFactory; public function __construct(ComposerJsonFactory $composerJsonFactory) { $this->composerJsonFactory = $composerJsonFactory; } public function run(): void { // ↓ instance of \Symplify\ComposerJsonManipulator\ValueObject\ComposerJson $composerJson = $this->composerJsonFactory->createFromFilePath(getcwd() . '/composer.json'); // Add a PRS-4 namespace $autoLoad = $composerJson->getAutoload(); $autoLoad['psr-4']['Cool\\Stuff\\'] = './lib/'; $composerJson->setAutoload($autoLoad); $this->jsonFileManager->printComposerJsonToFilePath($composerJson, $composerJson->getFileInfo()->getRealPath()); } }
Report Issues
In case you are experiencing a bug or want to request a new feature head over to the Symplify monorepo issue tracker
Contribute
The sources of this package are contained in the Symplify monorepo. We welcome contributions for this package on symplify/symplify.