public function installPackage(string $name, string $version, bool $dev = true)
    {
        $node = $dev ? 'require-dev' : 'require';

        if (array_key_exists($node, $this->definition)
            && array_key_exists($name, $this->definition[$node])
        ) {
            return;
        }

        $application = new Application();
        $command     = new RequireCommand();

        $definition = clone $application->getDefinition();
        $definition->addArguments($command->getDefinition()->getArguments());
        $definition->addOptions($command->getDefinition()->getOptions());

        $input = new ArrayInput(
            [
                'command' => 'require',
                'packages' => [$name . ':' . $version],
                '--dev' => $dev,
                '--no-scripts' => true,
                '--no-interaction' => true,
                '--no-plugins' => true,
                '--working-dir' => $this->workingDir
            ],
            $definition
        );

        $application->setAutoExit(false);
        $application->run($input, $this->output);
    }
public function installPackage(string $name, string $version, bool $dev = true)
    {
        $node = $dev ? 'require-dev' : 'require';

        if (array_key_exists($node, $this->definition)
            && array_key_exists($name, $this->definition[$node])
        ) {
            return;
        }

        $application = new Application();
        $command     = new RequireCommand();

        $definition = clone $application->getDefinition();
        $definition->addArguments($command->getDefinition()->getArguments());
        $definition->addOptions($command->getDefinition()->getOptions());

        $input = new ArrayInput(
            [
                'command' => 'require',
                'packages' => [$name . ':' . $version],
                '--dev' => $dev,
                '--no-scripts' => true,
                '--no-interaction' => true,
                '--no-plugins' => true,
                '--working-dir' => $this->workingDir
            ],
            $definition
        );

        $application->setAutoExit(false);
        $application->run($input, $this->output);
    }
public function installPackage ( string $ name , string $ version , bool $ dev = true ) { $ node = $ dev ? 'require-dev' : 'require' ; if ( array_key_exists ( $ node , $ this -> definition ) && array_key_exists ( $ name , $ this -> definition [ $ node ] ) ) { return ; } $ application = new Application ( ) ; $ command = new RequireCommand ( ) ; $ definition = clone $ application -> getDefinition ( ) ; $ definition -> addArguments ( $ command -> getDefinition ( ) -> getArguments ( ) ) ; $ definition -> addOptions ( $ command -> getDefinition ( ) -> getOptions ( ) ) ; $ input = new ArrayInput ( [ 'command' => 'require' , 'packages' => [ $ name . ':' . $ version ] , '--dev' => $ dev , '--no-scripts' => true , '--no-interaction' => true , '--no-plugins' => true , '--working-dir' => $ this -> workingDir ] , $ definition ) ; $ application -> setAutoExit ( false ) ; $ application -> run ( $ input , $ this -> output ) ; }
Install a composer package.

@param string $name
@param string $version
@param bool   $dev

@return void

@SuppressWarnings(PHPMD.BooleanArgumentFlag)
Install a composer package .