Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
<?php
/**
 * Created by PhpStorm.
 * User: danilo
 * Date: 18/12/15
 * Time: 10:58
 */
namespace Modules\Core\Services;

use Illuminate\Support\Composer as BaseComposer;
use Symfony\Component\Process\Process;

class Composer extends BaseComposer
{
    protected $outputHandler = null;
    private $output;

    /**
     * Enable real time output of all commands.
     *
     * @param $command
     * @return void
     */
    public function enableOutput($command)
    {
        $this->output = function ($type, $buffer) use ($command) {
            $info = '> ' . $buffer;
            if (Process::ERR === $type) {
                $info = '[ERR] ' . $info;
            }

            $command->info(trim($info));
        };
    }

    /**
     * Disable real time output of all commands.
     *
     * @return void
     */
    public function disableOutput()
    {
        $this->output = null;
    }

    /**
     * Update all composer packages.
     *
     * @param  string $package
     * @return void
     */
    public function update($package = null)
    {
        if (!is_null($package)) {
            $package = '"' . $package . '"';
        }
        $process = $this->getProcess();
        $process->setCommandLine(trim($this->findComposer() . ' update ' . $package));
        $process->run($this->output);
    }

    /**
     * Require a new composer package.
     *
     * @param  string $package
     * @return void
     */
    public function install($package)
    {
        if (!is_null($package)) {
            $package = '"' . $package . '"';
        }
        $process = $this->getProcess();
        $process->setCommandLine(trim($this->findComposer() . ' require ' . $package));
        $process->run($this->output);
    }

    /**
     * @return void
     */
    public function dumpAutoload()
    {
        $process = $this->getProcess();
        $process->setCommandLine(trim($this->findComposer() . ' dump-autoload -o'));
        $process->run($this->output);
    }

    public function remove($package)
    {
        if (!is_null($package)) {
            $package = '"' . $package . '"';
        }
        $process = $this->getProcess();
        $process->setCommandLine(trim($this->findComposer() . ' remove ' . $package));
        $process->run($this->output);
    }
}