namespace App\Http\Controllers;
use Mpociot\Blacksmith\Blacksmith;
use App\Models\Provider;
use App\Http\Requests;
use Illuminate\Http\Request;
use Symfony\Component\Process\Process;
use Symfony\Component\Process\Exception\ProcessFailedException;
class ForgeController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$blacksmith = new Blacksmith(env('FORGE_EMAIL'), env('FORGE_PASSWORD'));
$this->blacksmith = $blacksmith;
}
public function deployApp($provider_id)
{
$process = new Process('~/.composer/vendor/bin/envoy run updateenv --provider_id='.$provider_id);
$process->setTimeout(3600);
$process->setIdleTimeout(300);
$process->setWorkingDirectory(base_path());
$process->setEnhanceWindowsCompatibility(false);
$process->run();
// executes after the command finishes
if (!$process->isSuccessful()) {
throw new ProcessFailedException($process);
}
echo $process->getOutput();
}
}