PHP code example of jascha030 / cli

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

    

jascha030 / cli example snippets


interface ShellInterface
{
    /**
     * Run a shell command.
     */
    public function run(string $command, ?string $cwd = null, ?callable $onError = null): string;

    /**
     * Run a shell command with sudo user capabilities.
     */
    public function runAsUser(string $command, ?string $cwd = null, ?callable $onError = null): string;

    /**
     * Run a shell command without writing output to the STDOUT or php.
     */
    public function quietly(string $command, ?string $cwd = null, ?callable $onError = null): void;

    /**
     * Run a shell command with sudo user capabilities,  without writing output to the STDOUT or php.
     */
    public function quietlyAsUser(string $command, ?string $cwd = null, ?callable $onError = null): void;
}


public function runCommand(string $command, ?string $cwd = null, ?callable $onError = null): string;



use Jascha030\CLI\Shell\Shell;

/**
 * Include Composer's autoloader. 
 */
hod, as string.
echo $shell->run("`which php` -v");

$shell->quietly($command);

// This acts as if you run your command prepended by sudo.
$shell->runAsUser($command);

// Which also can be done silently.
$shell->quetlyAsUser($command);

// Runs the command two directories above the current script's directory.
$shell->run($command, dirname(__FILE__, 3));

interface BinaryInterface extends ShellInterface
{
    public function getName(): string;

    public function getPath(): string;

    public function getVersion(): ?string;
}
shell
php-cs-fixer fix --config=.php-cs-fixer.dist.php