Ejemplo n.º 1
0
 public function testCanGetReturnValue()
 {
     $shell = new System();
     $shell->run(new Command('ls 1>/dev/null'));
     $this->assertEquals(ExitCodes::SUCCESS, $shell->getReturnValue(), 'The return should be a success');
     $this->assertInternalType('integer', $shell->getReturnValue(), 'The should be a return value');
     $shell->run(new Command('/dev/null 2>/dev/null'));
     $this->assertEquals(ExitCodes::PERMISSION_ERROR, $shell->getReturnValue(), 'The return should be an error');
 }
Ejemplo n.º 2
0
use AdamBrett\ShellWrapper\Runners\ReturnValue;
use AdamBrett\ShellWrapper\Command\Builder as CommandBuilder;
$shell = new ShellExec();
$system = new System();
$cmd = $_POST['command'];
// XDebug Stuff
if ($cmd == 'xdebug') {
    $xdebugCommand = new Command($cmd);
    // $debugCheck = new CommandBuilder('php');
    // $debugCheck->addFlag('m')
    //         ->addFlag('c |')
    //         // ->addArgument('|')
    //         ->addArgument('grep xdebug');
    //         // ->addArgument('xdebug');
    $debugCheck = new Command('php -m -c | grep xdebug');
    $check = $system->run($debugCheck);
    echo "current check: " . $check;
    $inipath = php_ini_loaded_file();
    if ($inipath) {
        echo 'Loaded php.ini: ' . $inipath;
    } else {
        echo 'A php.ini file is not loaded';
    }
    if (empty($check) || $check == null) {
        // echo "CHECK IS NULL - Run DEBUG ON";
        $shell->run(new Command('xdebug_on'));
    } else {
        // echo "RUN XDEBUG OFF";
        $shell->run(new Command('xdebug_off'));
    }
}