Package to load, merge and save composer.json file(s)

Installs: 4 519 458

Dependents: 11

Suggesters: 0

Security: 0

Stars: 35

Watchers: 2

Forks: 0


This package is auto-updated.

Last update: 2022-05-22 13:49:08 UTC


Downloads total

  • load to composer.json to an object
  • use handful methods
  • merge it with others
  • print it back to composer.json in human-like format


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 {


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');
        // ...

Report Issues

In case you are experiencing a bug or want to request a new feature head over to the Symplify monorepo issue tracker


The sources of this package are contained in the Symplify monorepo. We welcome contributions for this package on symplify/symplify.