symplify/composer-json-manipulator

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

Installs: 688 906

Dependents: 9

Suggesters: 0

Security: 0

Stars: 11

Watchers: 1

Forks: 1

Type:symfony-bundle

9.0.45 2021-01-26 00:55 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.