1. Go to this page and download the library: Download phpsoftbox/code-generator 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/ */
phpsoftbox / code-generator example snippets
use PhpSoftBox\CodeGenerator\Cli\AbstractMakeCommandHandler;
use PhpSoftBox\CodeGenerator\CodeGenerator;
use PhpSoftBox\CodeGenerator\GeneratorTarget;
use PhpSoftBox\CliApp\Runner\RunnerInterface;
final class MakeFooHandler extends AbstractMakeCommandHandler
{
protected function missingNameMessage(): string
{
return 'Имя класса не задано.';
}
protected function successMessage(GeneratorTarget $target): string
{
return 'Создан класс: ' . $target->path;
}
protected function renderEvent(RunnerInterface $runner, GeneratorTarget $target): string
{
$generator = new CodeGenerator();
return $generator->renderClass(
className: $target->className,
namespace: $target->namespace,
);
}
}