symplify/composer-json-manipulator

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

Installs: 2 968 664

Dependents: 13

Suggesters: 0

Security: 0

Stars: 28

Watchers: 2

Forks: 0

Type:symfony-bundle

This package is auto-updated.

Last update: 2021-09-20 14:36:10 UTC


README

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

Install

composer require symplify/composer-json-manipulator

Add to config/bundles.php:

return [
    Symplify\ComposerJsonManipulator\Bundle\ComposerJsonManipulatorBundle::class => [
        'all' => true,
    ],
];

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

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.