TP6 常用指令

1、安装composer

curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer

2、composer镜像切换

  • 添加阿里云镜像
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
  • 取消全局镜像配置
composer config -g --unset repo.packagist
  • 查看全局配置信息
composer config -gl

3、安装

composer create-project topthink/think=6.0.* [目录名=think]

4、运行

php think run -p 80

5、多应用模式添加

composer require topthink/think-multi-app

6、创建中间件

app/middleware目录下面生成一个Check中间件

php think make:middleware Check

7、生成服务类

php think make:service  FileSystemService

8、控制其类创建

  • 单应用下创建控制器
php think make:controller Index
  • 在 admin 应用下创建控制器
php think make:controller admin@Index
  • 创建多级控制器
php think make:controller user/Profile

php think make:controller admin@user/Profile

9、生成模型类

  • protected $table = '表名'
// 单应用
php think make:model User

// 多应用
php think make:model admin@User

// 多级目录模型
php think make:model admin@user/Profile

10、引入视图扩展

composer require topthink/think-view

11、使用 trace 调试

composer require topthink/think-trace --dev

12、关闭 trace 调试

composer remove topthink/think-trace --dev

13、验证器类生成

在app目录下生成验证器类

  • app/validate/User.php
php think make:validate User
  • app/validate/admin/User.php
php think make:validate admin/User

在应用目录下生成验证器类

  • app/admin/validate/User.php
php think make:validate admin@User

14、生成应用

// 快速生成一个demo应用
php think build demo

// 快速生成一个index应用
php think build index

// 快速生成一个admin应用
php think build admin

你可能感兴趣的:(TP6 常用指令)