- N +

ThinkPHP6 基础命令

开发基础

安装 ThinkPHP

composer create-project topthink/think tp

更新 ThinkPHP

composer update topthink/framework

安装多应用模式扩展 think-multi-app

composer require topthink/think-multi-app

删除 app 目录下的 controller 目录

安装模板引擎驱动 think-view

composer require topthink/think-view

安装验证码扩展 think-captcha

composer require topthink/think-captcha

快速生成应用

php think build admin

应用结构自定义

app 目录下增加一个 build.php 文件

return [
    // 需要自动创建的文件
    '__file__'   => [],
    // 需要自动创建的目录
    '__dir__'    => ['controller', 'model', 'view'],
    // 需要自动创建的控制器
    'controller' => ['Index'],
    // 需要自动创建的模型
    'model'      => [],
    // 需要自动创建的模板
    'view'       => ['index/index'],
];

在根目录下 .example.env 文件复制更名为 .env,修改相关配置

多应用入口

public 目录下增加一个 admin.php 文件

<?php
// [ 应用入口文件 ]
namespace think;

require __DIR__ . '/../vendor/autoload.php';

// 执行HTTP应用并响应
$http = (new  App())->http;
$response = $http->name('admin')->run();
$response->send();
$http->end($response);

常用命令

资源控制器

php think make:controller admin@Article

空控制器

php think make:controller admin@Article --plain

模型

php think make:model admin@Article

验证器

php think make:validate admin@User

服务

php think make:service  FileSystemService

中间件

php think make:middleware Auth

事件

php think make:event UserLogin

清除缓存

php think clear

有好的文章希望我们帮助分享和推广,猛戳这里我要投稿

返回列表
上一篇:
下一篇:

发表评论中国互联网举报中心

快捷回复:

验证码

    评论列表 (暂无评论,共人参与)参与讨论

    还没有评论,来说两句吧...