PHP code example of waiterphp / builder

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

    

waiterphp / builder example snippets

 
#!/usr/bin/env php


use Builder\Input\Input;
use Builder\Output\Output;

/*注册项目命令文件夹*/
Application::addCommandNamespace(array('Command\\' => __DIR__.'/command'), $autoloader);

//运行命令
Application::getInstance()->run(new Input(), new Output());

Application::addCommandNamespace(array('Command\\' => __DIR__.'/command'), $autoloader);



namespace Command;

use Builder\Command\Command as BuildCommand;
use Builder\Input\InputInterface;
use Builder\Output\OutputInterface;

class Controller extends BuildCommand
{
    public $name = 'controller';
    
    public $description = '创建控制器';

    public function execute(InputInterface $input, OutputInterface $output)
    {
       $commandName = $input->get(0) . '......';
       $output->writeln('正在执行命令:' . $output->color($commandName, \Builder\Output\Color::F_GREEN));
       //命令之间的调用 命令名 传入的参数 如果调用的命令 php build controller -t sample_admin 则下面的参数可以省略model会直接从命令行参数取得
       
       parent::call('model', array('t'=>'sample_admin'));
    }
}
 


namespace Command;

use Builder\Command\Command as BuildCommand;
use Builder\Input\InputInterface;
use Builder\Output\OutputInterface;

class Model extends BuildCommand
{
    public $name = 'model';
    
    public $description = '创建表模型';

    public function execute(InputInterface $input, OutputInterface $output)
    {
       $tableName = $input->get('t');
       $output->writeln('要创建model的表名为:' . $output->color($tableName, \Builder\Output\Color::F_GREEN));
    }
}