<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jeffersongoncalves / laravel-zero-console example snippets
use Illuminate\Console\Command;
use JeffersonGoncalves\LaravelZero\Console\FormatsOutput;
class ListCommand extends Command
{
use FormatsOutput;
public function handle(): int
{
// Renders a table, or "No results found." when $rows is empty.
$this->renderTable(['ID', 'State', 'Updated'], $rows);
$this->line($this->colorize('OPEN', $this->stateColor('OPEN'))); // <fg=blue>OPEN</>
echo $this->formatDate('2024-01-02 03:04:05'); // 2024-01-02 03:04
echo $this->formatDate(null); // -
return self::SUCCESS;
}
}
use JeffersonGoncalves\LaravelZero\Console\HandlesApiErrors;
class FetchCommand extends Command
{
use HandlesApiErrors;
public function handle(): int
{
return $this->handleApiErrors(function () {
$data = $this->api->fetch(); // may throw any Throwable
$this->renderTable(['ID'], $data);
return self::SUCCESS;
});
}
}
use JeffersonGoncalves\LaravelZero\Console\ResolvesPath;
$path = $this->resolvePath($this->argument('path')); // realpath, or cwd when empty
$cwd = $this->resolveCwd(); // realpath of getcwd()
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.