PHP code example of roolith / generator

1. Go to this page and download the library: Download roolith/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/ */

    

roolith / generator example snippets



use Roolith\Generator\GeneratorFactory;


$generator
    ->setTemplateDirectory(__DIR__.'/template')
    ->setProjectBaseDirectory(__DIR__)
    ->watch($argv);


use Roolith\Generator\Command;
use Roolith\Generator\Console;
use Roolith\Generator\FileGenerator;
use Roolith\Generator\FileParser;
use Roolith\Generator\Interfaces\CommandInterface;

class TestCommand implements CommandInterface
{
    public function register()
    {
        return ['name' => 'test', 'alias' => [], 'typeAlias' => []];
    }

    public function handle(Command $command, Console $console, FileParser $fileParser, FileGenerator $fileGenerator)
    {
        $console->output('Test command registered!');
    }
}

$generator
    ->setTemplateDirectory(__DIR__.'/template')
    ->setProjectBaseDirectory(__DIR__)
    ->registerCommandClass([TestCommand::class])
    ->watch($argv);
text
# outputBaseDir: Controllers

namespace Something;

class {{name}} extends Controller
{
}
shell
php index.php generate controller DemoController
php index.php g c DemoController
shell
php index.php generate model User