feat: 本次提交更新内容如下
数据同步
This commit is contained in:
281
Server/thinkphp/library/think/console/Table.php
Normal file
281
Server/thinkphp/library/think/console/Table.php
Normal file
@@ -0,0 +1,281 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2015 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: yunwuxin <448901948@qq.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace think\console;
|
||||
|
||||
class Table
|
||||
{
|
||||
const ALIGN_LEFT = 1;
|
||||
const ALIGN_RIGHT = 0;
|
||||
const ALIGN_CENTER = 2;
|
||||
|
||||
/**
|
||||
* 头信息数据
|
||||
* @var array
|
||||
*/
|
||||
protected $header = [];
|
||||
|
||||
/**
|
||||
* 头部对齐方式 默认1 ALGIN_LEFT 0 ALIGN_RIGHT 2 ALIGN_CENTER
|
||||
* @var int
|
||||
*/
|
||||
protected $headerAlign = 1;
|
||||
|
||||
/**
|
||||
* 表格数据(二维数组)
|
||||
* @var array
|
||||
*/
|
||||
protected $rows = [];
|
||||
|
||||
/**
|
||||
* 单元格对齐方式 默认1 ALGIN_LEFT 0 ALIGN_RIGHT 2 ALIGN_CENTER
|
||||
* @var int
|
||||
*/
|
||||
protected $cellAlign = 1;
|
||||
|
||||
/**
|
||||
* 单元格宽度信息
|
||||
* @var array
|
||||
*/
|
||||
protected $colWidth = [];
|
||||
|
||||
/**
|
||||
* 表格输出样式
|
||||
* @var string
|
||||
*/
|
||||
protected $style = 'default';
|
||||
|
||||
/**
|
||||
* 表格样式定义
|
||||
* @var array
|
||||
*/
|
||||
protected $format = [
|
||||
'compact' => [],
|
||||
'default' => [
|
||||
'top' => ['+', '-', '+', '+'],
|
||||
'cell' => ['|', ' ', '|', '|'],
|
||||
'middle' => ['+', '-', '+', '+'],
|
||||
'bottom' => ['+', '-', '+', '+'],
|
||||
'cross-top' => ['+', '-', '-', '+'],
|
||||
'cross-bottom' => ['+', '-', '-', '+'],
|
||||
],
|
||||
'markdown' => [
|
||||
'top' => [' ', ' ', ' ', ' '],
|
||||
'cell' => ['|', ' ', '|', '|'],
|
||||
'middle' => ['|', '-', '|', '|'],
|
||||
'bottom' => [' ', ' ', ' ', ' '],
|
||||
'cross-top' => ['|', ' ', ' ', '|'],
|
||||
'cross-bottom' => ['|', ' ', ' ', '|'],
|
||||
],
|
||||
'borderless' => [
|
||||
'top' => ['=', '=', ' ', '='],
|
||||
'cell' => [' ', ' ', ' ', ' '],
|
||||
'middle' => ['=', '=', ' ', '='],
|
||||
'bottom' => ['=', '=', ' ', '='],
|
||||
'cross-top' => ['=', '=', ' ', '='],
|
||||
'cross-bottom' => ['=', '=', ' ', '='],
|
||||
],
|
||||
'box' => [
|
||||
'top' => ['┌', '─', '┬', '┐'],
|
||||
'cell' => ['│', ' ', '│', '│'],
|
||||
'middle' => ['├', '─', '┼', '┤'],
|
||||
'bottom' => ['└', '─', '┴', '┘'],
|
||||
'cross-top' => ['├', '─', '┴', '┤'],
|
||||
'cross-bottom' => ['├', '─', '┬', '┤'],
|
||||
],
|
||||
'box-double' => [
|
||||
'top' => ['╔', '═', '╤', '╗'],
|
||||
'cell' => ['║', ' ', '│', '║'],
|
||||
'middle' => ['╠', '─', '╪', '╣'],
|
||||
'bottom' => ['╚', '═', '╧', '╝'],
|
||||
'cross-top' => ['╠', '═', '╧', '╣'],
|
||||
'cross-bottom' => ['╠', '═', '╤', '╣'],
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* 设置表格头信息 以及对齐方式
|
||||
* @access public
|
||||
* @param array $header 要输出的Header信息
|
||||
* @param int $align 对齐方式 默认1 ALGIN_LEFT 0 ALIGN_RIGHT 2 ALIGN_CENTER
|
||||
* @return void
|
||||
*/
|
||||
public function setHeader(array $header, $align = self::ALIGN_LEFT)
|
||||
{
|
||||
$this->header = $header;
|
||||
$this->headerAlign = $align;
|
||||
|
||||
$this->checkColWidth($header);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置输出表格数据 及对齐方式
|
||||
* @access public
|
||||
* @param array $rows 要输出的表格数据(二维数组)
|
||||
* @param int $align 对齐方式 默认1 ALGIN_LEFT 0 ALIGN_RIGHT 2 ALIGN_CENTER
|
||||
* @return void
|
||||
*/
|
||||
public function setRows(array $rows, $align = self::ALIGN_LEFT)
|
||||
{
|
||||
$this->rows = $rows;
|
||||
$this->cellAlign = $align;
|
||||
|
||||
foreach ($rows as $row) {
|
||||
$this->checkColWidth($row);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查列数据的显示宽度
|
||||
* @access public
|
||||
* @param mixed $row 行数据
|
||||
* @return void
|
||||
*/
|
||||
protected function checkColWidth($row)
|
||||
{
|
||||
if (is_array($row)) {
|
||||
foreach ($row as $key => $cell) {
|
||||
if (!isset($this->colWidth[$key]) || strlen($cell) > $this->colWidth[$key]) {
|
||||
$this->colWidth[$key] = strlen($cell);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加一行表格数据
|
||||
* @access public
|
||||
* @param mixed $row 行数据
|
||||
* @param bool $first 是否在开头插入
|
||||
* @return void
|
||||
*/
|
||||
public function addRow($row, $first = false)
|
||||
{
|
||||
if ($first) {
|
||||
array_unshift($this->rows, $row);
|
||||
} else {
|
||||
$this->rows[] = $row;
|
||||
}
|
||||
|
||||
$this->checkColWidth($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置输出表格的样式
|
||||
* @access public
|
||||
* @param string $style 样式名
|
||||
* @return void
|
||||
*/
|
||||
public function setStyle($style)
|
||||
{
|
||||
$this->style = isset($this->format[$style]) ? $style : 'default';
|
||||
}
|
||||
|
||||
/**
|
||||
* 输出分隔行
|
||||
* @access public
|
||||
* @param string $pos 位置
|
||||
* @return string
|
||||
*/
|
||||
protected function renderSeparator($pos)
|
||||
{
|
||||
$style = $this->getStyle($pos);
|
||||
$array = [];
|
||||
|
||||
foreach ($this->colWidth as $width) {
|
||||
$array[] = str_repeat($style[1], $width + 2);
|
||||
}
|
||||
|
||||
return $style[0] . implode($style[2], $array) . $style[3] . PHP_EOL;
|
||||
}
|
||||
|
||||
/**
|
||||
* 输出表格头部
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
protected function renderHeader()
|
||||
{
|
||||
$style = $this->getStyle('cell');
|
||||
$content = $this->renderSeparator('top');
|
||||
|
||||
foreach ($this->header as $key => $header) {
|
||||
$array[] = ' ' . str_pad($header, $this->colWidth[$key], $style[1], $this->headerAlign);
|
||||
}
|
||||
|
||||
if (!empty($array)) {
|
||||
$content .= $style[0] . implode(' ' . $style[2], $array) . ' ' . $style[3] . PHP_EOL;
|
||||
|
||||
if ($this->rows) {
|
||||
$content .= $this->renderSeparator('middle');
|
||||
}
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
protected function getStyle($style)
|
||||
{
|
||||
if ($this->format[$this->style]) {
|
||||
$style = $this->format[$this->style][$style];
|
||||
} else {
|
||||
$style = [' ', ' ', ' ', ' '];
|
||||
}
|
||||
|
||||
return $style;
|
||||
}
|
||||
|
||||
/**
|
||||
* 输出表格
|
||||
* @access public
|
||||
* @param array $dataList 表格数据
|
||||
* @return string
|
||||
*/
|
||||
public function render($dataList = [])
|
||||
{
|
||||
if ($dataList) {
|
||||
$this->setRows($dataList);
|
||||
}
|
||||
|
||||
// 输出头部
|
||||
$content = $this->renderHeader();
|
||||
$style = $this->getStyle('cell');
|
||||
|
||||
if ($this->rows) {
|
||||
foreach ($this->rows as $row) {
|
||||
if (is_string($row) && '-' === $row) {
|
||||
$content .= $this->renderSeparator('middle');
|
||||
} elseif (is_scalar($row)) {
|
||||
$content .= $this->renderSeparator('cross-top');
|
||||
$array = str_pad($row, 3 * (count($this->colWidth) - 1) + array_reduce($this->colWidth, function ($a, $b) {
|
||||
return $a + $b;
|
||||
}));
|
||||
|
||||
$content .= $style[0] . ' ' . $array . ' ' . $style[3] . PHP_EOL;
|
||||
$content .= $this->renderSeparator('cross-bottom');
|
||||
} else {
|
||||
$array = [];
|
||||
|
||||
foreach ($row as $key => $val) {
|
||||
$array[] = ' ' . str_pad($val, $this->colWidth[$key], ' ', $this->cellAlign);
|
||||
}
|
||||
|
||||
$content .= $style[0] . implode(' ' . $style[2], $array) . ' ' . $style[3] . PHP_EOL;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$content .= $this->renderSeparator('bottom');
|
||||
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
130
Server/thinkphp/library/think/console/command/RouteList.php
Normal file
130
Server/thinkphp/library/think/console/command/RouteList.php
Normal file
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: yunwuxin <448901948@qq.com>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace think\console\command;
|
||||
|
||||
use think\console\Command;
|
||||
use think\console\Input;
|
||||
use think\console\input\Argument;
|
||||
use think\console\input\Option;
|
||||
use think\console\Output;
|
||||
use think\console\Table;
|
||||
use think\Container;
|
||||
|
||||
class RouteList extends Command
|
||||
{
|
||||
protected $sortBy = [
|
||||
'rule' => 0,
|
||||
'route' => 1,
|
||||
'method' => 2,
|
||||
'name' => 3,
|
||||
'domain' => 4,
|
||||
];
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('route:list')
|
||||
->addArgument('style', Argument::OPTIONAL, "the style of the table.", 'default')
|
||||
->addOption('sort', 's', Option::VALUE_OPTIONAL, 'order by rule name.', 0)
|
||||
->addOption('more', 'm', Option::VALUE_NONE, 'show route options.')
|
||||
->setDescription('show route list.');
|
||||
}
|
||||
|
||||
protected function execute(Input $input, Output $output)
|
||||
{
|
||||
$filename = Container::get('app')->getRuntimePath() . 'route_list.php';
|
||||
|
||||
if (is_file($filename)) {
|
||||
unlink($filename);
|
||||
}
|
||||
|
||||
$content = $this->getRouteList();
|
||||
file_put_contents($filename, 'Route List' . PHP_EOL . $content);
|
||||
}
|
||||
|
||||
protected function getRouteList()
|
||||
{
|
||||
Container::get('route')->setTestMode(true);
|
||||
// 路由检测
|
||||
$path = Container::get('app')->getRoutePath();
|
||||
|
||||
$files = is_dir($path) ? scandir($path) : [];
|
||||
|
||||
foreach ($files as $file) {
|
||||
if (strpos($file, '.php')) {
|
||||
$filename = $path . DIRECTORY_SEPARATOR . $file;
|
||||
// 导入路由配置
|
||||
$rules = include $filename;
|
||||
|
||||
if (is_array($rules)) {
|
||||
Container::get('route')->import($rules);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Container::get('config')->get('route_annotation')) {
|
||||
$suffix = Container::get('config')->get('controller_suffix') || Container::get('config')->get('class_suffix');
|
||||
|
||||
include Container::get('build')->buildRoute($suffix);
|
||||
}
|
||||
|
||||
$table = new Table();
|
||||
|
||||
if ($this->input->hasOption('more')) {
|
||||
$header = ['Rule', 'Route', 'Method', 'Name', 'Domain', 'Option', 'Pattern'];
|
||||
} else {
|
||||
$header = ['Rule', 'Route', 'Method', 'Name', 'Domain'];
|
||||
}
|
||||
|
||||
$table->setHeader($header);
|
||||
|
||||
$routeList = Container::get('route')->getRuleList();
|
||||
$rows = [];
|
||||
|
||||
foreach ($routeList as $domain => $items) {
|
||||
foreach ($items as $item) {
|
||||
$item['route'] = $item['route'] instanceof \Closure ? '<Closure>' : $item['route'];
|
||||
|
||||
if ($this->input->hasOption('more')) {
|
||||
$item = [$item['rule'], $item['route'], $item['method'], $item['name'], $domain, json_encode($item['option']), json_encode($item['pattern'])];
|
||||
} else {
|
||||
$item = [$item['rule'], $item['route'], $item['method'], $item['name'], $domain];
|
||||
}
|
||||
|
||||
$rows[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->input->getOption('sort')) {
|
||||
$sort = $this->input->getOption('sort');
|
||||
|
||||
if (isset($this->sortBy[$sort])) {
|
||||
$sort = $this->sortBy[$sort];
|
||||
}
|
||||
|
||||
uasort($rows, function ($a, $b) use ($sort) {
|
||||
$itemA = isset($a[$sort]) ? $a[$sort] : null;
|
||||
$itemB = isset($b[$sort]) ? $b[$sort] : null;
|
||||
|
||||
return strcasecmp($itemA, $itemB);
|
||||
});
|
||||
}
|
||||
|
||||
$table->setRows($rows);
|
||||
|
||||
if ($this->input->getArgument('style')) {
|
||||
$style = $this->input->getArgument('style');
|
||||
$table->setStyle($style);
|
||||
}
|
||||
|
||||
return $this->table($table);
|
||||
}
|
||||
|
||||
}
|
||||
53
Server/thinkphp/library/think/console/command/RunServer.php
Normal file
53
Server/thinkphp/library/think/console/command/RunServer.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2015 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: Slince <taosikai@yeah.net>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace think\console\command;
|
||||
|
||||
use think\console\Command;
|
||||
use think\console\Input;
|
||||
use think\console\input\Option;
|
||||
use think\console\Output;
|
||||
use think\facade\App;
|
||||
|
||||
class RunServer extends Command
|
||||
{
|
||||
public function configure()
|
||||
{
|
||||
$this->setName('run')
|
||||
->addOption('host', 'H', Option::VALUE_OPTIONAL,
|
||||
'The host to server the application on', '127.0.0.1')
|
||||
->addOption('port', 'p', Option::VALUE_OPTIONAL,
|
||||
'The port to server the application on', 8000)
|
||||
->addOption('root', 'r', Option::VALUE_OPTIONAL,
|
||||
'The document root of the application', App::getRootPath() . 'public')
|
||||
->setDescription('PHP Built-in Server for ThinkPHP');
|
||||
}
|
||||
|
||||
public function execute(Input $input, Output $output)
|
||||
{
|
||||
$host = $input->getOption('host');
|
||||
$port = $input->getOption('port');
|
||||
$root = $input->getOption('root');
|
||||
|
||||
$command = sprintf(
|
||||
'php -S %s:%d -t %s %s',
|
||||
$host,
|
||||
$port,
|
||||
escapeshellarg($root),
|
||||
escapeshellarg($root . DIRECTORY_SEPARATOR . 'router.php')
|
||||
);
|
||||
|
||||
$output->writeln(sprintf('ThinkPHP Development server is started On <http://%s:%s/>', $host, $port));
|
||||
$output->writeln(sprintf('You can exit with <info>`CTRL-C`</info>'));
|
||||
$output->writeln(sprintf('Document root is: %s', $root));
|
||||
passthru($command);
|
||||
}
|
||||
|
||||
}
|
||||
31
Server/thinkphp/library/think/console/command/Version.php
Normal file
31
Server/thinkphp/library/think/console/command/Version.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: liu21st <liu21st@gmail.com>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace think\console\command;
|
||||
|
||||
use think\console\Command;
|
||||
use think\console\Input;
|
||||
use think\console\Output;
|
||||
use think\facade\App;
|
||||
|
||||
class Version extends Command
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
// 指令配置
|
||||
$this->setName('version')
|
||||
->setDescription('show thinkphp framework version');
|
||||
}
|
||||
|
||||
protected function execute(Input $input, Output $output)
|
||||
{
|
||||
$output->writeln('v' . App::version());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: 刘志淳 <chun@engineer.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace think\console\command\make;
|
||||
|
||||
use think\console\command\Make;
|
||||
use think\console\input\Argument;
|
||||
use think\facade\App;
|
||||
|
||||
class Command extends Make
|
||||
{
|
||||
protected $type = "Command";
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
parent::configure();
|
||||
$this->setName('make:command')
|
||||
->addArgument('commandName', Argument::OPTIONAL, "The name of the command")
|
||||
->setDescription('Create a new command class');
|
||||
}
|
||||
|
||||
protected function buildClass($name)
|
||||
{
|
||||
$commandName = $this->input->getArgument('commandName') ?: strtolower(basename($name));
|
||||
$namespace = trim(implode('\\', array_slice(explode('\\', $name), 0, -1)), '\\');
|
||||
|
||||
$class = str_replace($namespace . '\\', '', $name);
|
||||
$stub = file_get_contents($this->getStub());
|
||||
|
||||
return str_replace(['{%commandName%}', '{%className%}', '{%namespace%}', '{%app_namespace%}'], [
|
||||
$commandName,
|
||||
$class,
|
||||
$namespace,
|
||||
App::getNamespace(),
|
||||
], $stub);
|
||||
}
|
||||
|
||||
protected function getStub()
|
||||
{
|
||||
return __DIR__ . DIRECTORY_SEPARATOR . 'stubs' . DIRECTORY_SEPARATOR . 'command.stub';
|
||||
}
|
||||
|
||||
protected function getNamespace($appNamespace, $module)
|
||||
{
|
||||
return $appNamespace . '\\command';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: 刘志淳 <chun@engineer.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace think\console\command\make;
|
||||
|
||||
use think\console\command\Make;
|
||||
|
||||
class Middleware extends Make
|
||||
{
|
||||
protected $type = "Middleware";
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
parent::configure();
|
||||
$this->setName('make:middleware')
|
||||
->setDescription('Create a new middleware class');
|
||||
}
|
||||
|
||||
protected function getStub()
|
||||
{
|
||||
return __DIR__ . DIRECTORY_SEPARATOR . 'stubs' . DIRECTORY_SEPARATOR . 'middleware.stub';
|
||||
}
|
||||
|
||||
protected function getNamespace($appNamespace, $module)
|
||||
{
|
||||
return parent::getNamespace($appNamespace, 'http') . '\middleware';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: 刘志淳 <chun@engineer.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace think\console\command\make;
|
||||
|
||||
use think\console\command\Make;
|
||||
|
||||
class Validate extends Make
|
||||
{
|
||||
protected $type = "Validate";
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
parent::configure();
|
||||
$this->setName('make:validate')
|
||||
->setDescription('Create a validate class');
|
||||
}
|
||||
|
||||
protected function getStub()
|
||||
{
|
||||
$stubPath = __DIR__ . DIRECTORY_SEPARATOR . 'stubs' . DIRECTORY_SEPARATOR;
|
||||
|
||||
return $stubPath . 'validate.stub';
|
||||
}
|
||||
|
||||
protected function getNamespace($appNamespace, $module)
|
||||
{
|
||||
return parent::getNamespace($appNamespace, $module) . '\validate';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace {%namespace%};
|
||||
|
||||
use think\console\Command;
|
||||
use think\console\Input;
|
||||
use think\console\Output;
|
||||
|
||||
class {%className%} extends Command
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
// 指令配置
|
||||
$this->setName('{%commandName%}');
|
||||
// 设置参数
|
||||
|
||||
}
|
||||
|
||||
protected function execute(Input $input, Output $output)
|
||||
{
|
||||
// 指令输出
|
||||
$output->writeln('{%commandName%}');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace {%namespace%};
|
||||
|
||||
use think\Controller;
|
||||
use think\Request;
|
||||
|
||||
class {%className%} extends Controller
|
||||
{
|
||||
/**
|
||||
* 显示资源列表
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function index{%actionSuffix%}()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新建的资源
|
||||
*
|
||||
* @param \think\Request $request
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function save{%actionSuffix%}(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示指定的资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function read{%actionSuffix%}($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存更新的资源
|
||||
*
|
||||
* @param \think\Request $request
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function update{%actionSuffix%}(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function delete{%actionSuffix%}($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace {%namespace%};
|
||||
|
||||
class {%className%}
|
||||
{
|
||||
public function handle($request, \Closure $next)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace {%namespace%};
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class {%className%} extends Validate
|
||||
{
|
||||
/**
|
||||
* 定义验证规则
|
||||
* 格式:'字段名' => ['规则1','规则2'...]
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $rule = [];
|
||||
|
||||
/**
|
||||
* 定义错误信息
|
||||
* 格式:'字段名.规则名' => '错误信息'
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $message = [];
|
||||
}
|
||||
Reference in New Issue
Block a user