PHP code example of mikhailovlab / php-fluent-console
1. Go to this page and download the library: Download mikhailovlab/php-fluent-console 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/ */
mikhailovlab / php-fluent-console example snippets
public function setCommand(string $cmd): self
public function addKey(string $key): self
public function encoding(?string $encoding = null): self
public function decoding(): self
public function getCommand(): string
public function run(): bool
public function getOutput(): array
public function getReturnCode(): int
public function hasError(string $pattern): bool
public function getMatches(string|array $patterns): array
$cli = new ConsoleRunner();
$cli->setCommand('ipconfig')
->addKey('/all');
// Optional encoding for Cyrillic output
// ->encoding('866')
// ->decoding();
if ($cli->run()) {
print_r($cli->getOutput());
exit();
}
exit('Error, code: ' . $cli->getReturnCode());