PHP code example of eta-orionis / composer-json-manipulator

1. Go to this page and download the library: Download eta-orionis/composer-json-manipulator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

eta-orionis / composer-json-manipulator example snippets


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