PHP code example of adambrett / shell-wrapper

1. Go to this page and download the library: Download adambrett/shell-wrapper library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

adambrett / shell-wrapper example snippets


use AdamBrett\ShellWrapper\Command;
use AdamBrett\ShellWrapper\Command\Param;
use AdamBrett\ShellWrapper\Runners\Exec;

$shell = new Exec();

$command = new Command('echo');

$command->addParam(new Param('Hello World'));

$shell->run($command);

use AdamBrett\ShellWrapper\Runners\Exec;
use AdamBrett\ShellWrapper\Command\Builder as CommandBuilder;

$shell = new Exec();
$command = new CommandBuilder('echo');
$command->addParam('Hello World');
$shell->run($command);

use AdamBrett\ShellWrapper\Runners\Exec;
use AdamBrett\ShellWrapper\Command\Builder as CommandBuilder;

$shell = new Exec();
$command = new CommandBuilder('phpunit');
$command->addFlag('v')
    ->addArgument('stop-on-failure')
    ->addArgument('configuration', '~/phpunit.xml')
    ->addParam('~/tests/TestCase.php');
$shell->run($command);

use AdamBrett\ShellWrapper\Runners\Exec;
use AdamBrett\ShellWrapper\Command\Builder as CommandBuilder;

$shell = new Exec();
$command = new CommandBuilder('/usr/bin/jekyll');
$command->addSubCommand('serve')
    ->addArgument('watch');
$shell->run($command);

use AdamBrett\ShellWrapper\Command\SubCommand;

$shell->addSubCommand(new SubCommand($subCommand));

use AdamBrett\ShellWrapper\Command\Command;
use AdamBrett\ShellWrapper\Command\SubCommand;

$command = new Command('jekyll')
$shell->addSubCommand(new SubCommand('build'));

use AdamBrett\ShellWrapper\Command\Argument;

$shell->addArgument(new Argument($name, $value));

use AdamBrett\ShellWrapper\Command\Argument;

$shell->addArgument(new Argument('exclude', ['.git*', 'cache']));

use AdamBrett\ShellWrapper\Command\Flag;

$shell->addFlag(new Flag($flag));

use AdamBrett\ShellWrapper\Command\Param;

$shell->addParam(new Param($param));
bash
echo 'Hello World'