1. Go to this page and download the library: Download utopia-php/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/ */
utopia-php / console example snippets
Utopia\Console\Console;
use Utopia\Console\Command;
Console::success('Ready to work!');
$answer = Console::confirm('Continue? [y/N]');
if ($answer !== 'y') {
Console::warning('Aborting...');
Console::exit(1);
}
$output = '';
$stderr = '';
$command = new Command(PHP_BINARY)
->option('-r', 'echo "Hello";');
$exitCode = Console::execute($command, '', $output, $stderr, 3);
Console::log("Command returned {$exitCode} with: {$output}");
$command = new Command('tar')
->flag('-cz')
->option('-f', 'archive.tar.gz')
->option('-C', '/tmp/project')
->argument('.');
$pipeline = Command::pipe(
new Command('ps')->flag('-ef'),
new Command('grep')->argument('php-fpm'),
new Command('wc')->flag('-l'),
);
$deploy = Command::and(
Command::group(
Command::or(
new Command('build'),
new Command('build:fallback'),
)
),
new Command('publish'),
);
$logs = Command::appendStdout(
Command::pipe(
new Command('cat')->argument('app.log'),
new Command('grep')->argument('ERROR'),
),
'errors.log',
);
use Utopia\Console\Console;
Console::loop(function () {
echo "Hello World\n";
}, 1); // 1 second
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.