1. Go to this page and download the library: Download devsrealm/tonics-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/ */
devsrealm / tonics-console example snippets
evsrealm\TonicsConsole\ProcessCommandLineArgs;
$args = ['--name=John', '--age=30', '-v'];
$processArgs = new ProcessCommandLineArgs($args);
if ($processArgs->passes()) {
$parsedArgs = $processArgs->getProcessArgs();
print_r($parsedArgs);
} else {
echo "No valid arguments passed.";
}
use Devsrealm\TonicsConsole\Interfaces\ConsoleCommand;
class EnvManageCommand implements ConsoleCommand
{
public function s): void
{
// ...
}
}
use Devsrealm\TonicsConsole\Helpers\ArgsHelper;
// presence checks (wildcard supported)
ArgsHelper::has($args, '--env*');
// get exact or wildcard map
$value = ArgsHelper::get($args, '--file', 'default');
$envMap = ArgsHelper::get($args, '--env*'); // [ '--env:manage' => '', '--env:list' => '', ... ]
// always return array for a key (promote scalar/flag to array)
$sets = ArgsHelper::getAsArray($args, '--set');
// treat empty-string flags as boolean true
$verbose = ArgsHelper::valueOrFlag($args, '-v', true, false);
// filter by patterns
$envArgs = ArgsHelper::filter($args, '--env*');
// validate
use Devsrealm\TonicsConsole\Interfaces\DescribedConsoleCommand;
// Generic command
class MigrateAll implements ConsoleCommand
{
public function ommandOptions): void
{
// Runs basic migration
}
}
// More specific command
class MigrateAllFresh implements ConsoleCommand
{
public function
public function __construct(array $args)
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.