Repository URL to install this package:
|
Version:
1.0.0 ▾
|
<?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);
}
}