PHP code example of digipolisgent / command-builder
1. Go to this page and download the library: Download digipolisgent/command-builder 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/ */
digipolisgent / command-builder example snippets
igipolisGent\CommandBuilder\CommandBuilder;
$builder = CommandBuilder::create('ls')
->addFlag('a')
->addFlag('l')
->pipeOutputTo('grep')
->addArgument('mydir')
->onSuccess('echo')
->addArgument('mydir already exists')
->onFailure(
CommandBuilder::create('mkdir')
->addArgument('mydir')
->onSuccess('echo')
->addArgument('mydir created')
);
print $builder;
sh
{ { { ls -a -l | grep 'mydir'; } && echo 'mydir already exists'; } || { mkdir 'mydir' && echo 'mydir created'; }; }