PHP code example of posternak / commandeer

1. Go to this page and download the library: Download posternak/commandeer 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/ */

    

posternak / commandeer example snippets


use Posternak\Commandeer\ShellCommand;

$command = new ShellCommand('git status');
$command->run();

if ($command->succeeded()) {
    $output = $command->getOutput(); // array of lines
}

use Posternak\Commandeer\Builders\Cmd;

// docker ps -a
Cmd::docker()->ps()->_a()->run();

// kubectl get pods -o json
Cmd::kubectl()->get('pods')->_o('json')->run();

// npm install
Cmd::npm()->install()->run();

// git log --pretty oneline
Cmd::git()->log()->pretty('oneline')->run();

use Posternak\Commandeer\Builders\Git;
use Posternak\Commandeer\Builders\Composer;

// Instead of Cmd::git()
Git::status()->porcelain()->run();

// Instead of Cmd::composer()
Composer::

Git::addEverything(); // git add .
Git::commitWithMessage('feat: add feature'); // git commit -m "..."
Git::pushToOrigin('main'); // git push origin main