README.md

    环境变量

    XDEBUG_CONFIG="idekey=VSCODE" XDEBUG=vscode

    快捷键

    ctrl/command + shift + k //删除当前行

    cli

    php think run php think make:model composer create-project topthink/think=~6.0 demotp6 composer create-project topthink/think=~8.0 demotp8 composer create-project topthink/think=~5 demotp5 composer create-project laravel/laravel demolaravel composer require --dev phpunit/phpunit:10.5

    composer create-project thinkcmf/thinkcmf=~6.0 demothinkcmf6 composer create-project thinkcmf/thinkcmf=~8.0 demothinkcmf8 ln -s /usr/local/etc/php/8.2/ php82

    /usr/local/opt/mysql@5.7/bin/mysqld_safe --datadir=/usr/local/var/mysql

    ./vendor/bin/phpunit -dxdebug.mode=debug -dxdebug.start_with_request=yes -dxdebug.client_host=localhost -dxdebug.client_port=9003 tests/DemoTest.php
    php -dxdebug.mode=debug -dxdebug.start_with_request=yes -dxdebug.client_host=localhost -dxdebug.client_port=9003 index.php php ../phpunit-10.5.13.phar tests/DemoTest.php php ../phpunit-10.5.13.phar --help php -dxdebug.mode=debug -dxdebug.start_with_request=yes -dxdebug.client_host=localhost -dxdebug.client_port=9003 ../phpunit-10.5.13.phar tests/DemoTest.php

    1192129692@qq.com

    恭喜您,安装完成!

    为了您的站点安全,安装完成后您有两种方式删除安装程序 1.将"vendor/thinkcmf/cmf-install"文件夹删除; 2.最好执行"composer remove thinkcmf/cmf-install"删除! 另请对data/config/database.php文件做好备份,以防丢失!

    vscode config

    "editor.quickSuggestions": { "other": true, "comments": true, "strings": true }

    "editor.wordSeparators": "`~!@#%^&*()-=+[{]}\|;:'",.<>/?"

    snippets

    "$$$$$$":{
    	"prefix": "ss",
    	"body": "$$1",
    	"description": "$$$$$$$"
    }

    Class Model

    • @method static $this scope(string|array $scope) static 查询范围
    • @method static $this where(mixed $field, string $op = null, mixed $condition = null) static 查询条件
    • @method static $this whereRaw(string $where, array $bind = [], string $logic = 'AND') static 表达式查询
    • @method static $this whereExp(string $field, string $condition, array $bind = [], string $logic = 'AND') static 字段表达式查询
    • @method static $this when(mixed $condition, mixed $query, mixed $otherwise = null) static 条件查询
    • @method static $this join(mixed $join, mixed $condition = null, string $type = 'INNER', array $bind = []) static JOIN查询
    • @method static $this view(mixed $join, mixed $field = null, mixed $on = null, string $type = 'INNER') static 视图查询
    • @method static $this with(mixed $with, callable $callback = null) static 关联预载入
    • @method static $this count(string $field = '*') static Count统计查询
    • @method static $this min(string $field, bool $force = true) static Min统计查询
    • @method static $this max(string $field, bool $force = true) static Max统计查询
    • @method static $this sum(string $field) static SUM统计查询
    • @method static $this avg(string $field) static Avg统计查询
    • @method static $this field(mixed $field, boolean $except = false, string $tableName = '', string $prefix = '', string $alias = '') static 指定查询字段
    • @method static $this fieldRaw(string $field) static 指定查询字段
    • @method static $this union(mixed $union, boolean $all = false) static UNION查询
    • @method static $this limit(mixed $offset, integer $length = null) static 查询LIMIT
    • @method static $this order(mixed $field, string $order = null) static 查询ORDER
    • @method static $this orderRaw(string $field, array $bind = []) static 查询ORDER
    • @method static $this cache(mixed $key = null, integer|\DateTime $expire = null, string $tag = null) static 设置查询缓存
    • @method static mixed value(string $field, mixed $default = null) static 获取某个字段的值
    • @method static array column(string $field, string $key = '') static 获取某个列的值
    • @method static $this find(mixed $data = null) static 查询单个记录
    • @method static $this findOrFail(mixed $data = null) 查询单个记录
    • @method static \think\Model\Collection|$this[] select(mixed $data = null) static 查询多个记录
    • @method static $this get(mixed $data = null, mixed $with = [], bool $cache = false, bool $failException = false) static 查询单个记录 支持关联预载入
    • @method static $this getOrFail(mixed $data = null, mixed $with = [], bool $cache = false) static 查询单个记录 不存在则抛出异常
    • @method static $this findOrEmpty(mixed $data = null) static 查询单个记录 不存在则返回空模型
    • @method static Collection|$this[] all(mixed $data = null, mixed $with = [], bool $cache = false) static 查询多个记录 支持关联预载入
    • @method static $this withAttr(array $name, \Closure $closure = null) static 动态定义获取器
    • @method static $this withJoin(string|array $with, string $joinType = '') static
    • @method static $this withCount(string|array $relation, bool $subQuery = true) static 关联统计
    • @method static $this withSum(string|array $relation, string $field, bool $subQuery = true) static 关联SUM统计
    • @method static $this withMax(string|array $relation, string $field, bool $subQuery = true) static 关联MAX统计
    • @method static $this withMin(string|array $relation, string $field, bool $subQuery = true) static 关联Min统计
    • @method static $this withAvg(string|array $relation, string $field, bool $subQuery = true) static 关联Avg统计
    • @method Paginator|$this paginate(int|array $listRows = null, int|bool $simple = false, array $config = []) static 分页

    DbManager

    • @method static \think\db\Query master() static 从主服务器读取数据
    • @method static \think\db\Query readMaster(bool $all = false) static 后续从主服务器读取数据
    • @method static \think\db\Query table(string $table) static 指定数据表(含前缀)
    • @method static \think\db\Query name(string $name) static 指定数据表(不含前缀)
    • @method static \think\db\Expression raw(string $value) static 使用表达式设置数据
    • @method static \think\db\Query where(mixed $field, string $op = null, mixed $condition = null) static 查询条件
    • @method static \think\db\Query whereRaw(string $where, array $bind = []) static 表达式查询
    • @method static \think\db\Query whereExp(string $field, string $condition, array $bind = []) static 字段表达式查询
    • @method static \think\db\Query when(mixed $condition, mixed $query, mixed $otherwise = null) static 条件查询
    • @method static \think\db\Query join(mixed $join, mixed $condition = null, string $type = 'INNER') static JOIN查询
    • @method static \think\db\Query view(mixed $join, mixed $field = null, mixed $on = null, string $type = 'INNER') static 视图查询
    • @method static \think\db\Query field(mixed $field, boolean $except = false) static 指定查询字段
    • @method static \think\db\Query fieldRaw(string $field, array $bind = []) static 指定查询字段
    • @method static \think\db\Query union(mixed $union, boolean $all = false) static UNION查询
    • @method static \think\db\Query limit(mixed $offset, integer $length = null) static 查询LIMIT
    • @method static \think\db\Query order(mixed $field, string $order = null) static 查询ORDER
    • @method static \think\db\Query orderRaw(string $field, array $bind = []) static 查询ORDER
    • @method static \think\db\Query cache(mixed $key = null , integer $expire = null) static 设置查询缓存
    • @method static \think\db\Query withAttr(string $name,callable $callback = null) static 使用获取器获取数据
    • @method static mixed value(string $field) static 获取某个字段的值
    • @method static array column(string $field, string $key = '') static 获取某个列的值
    • @method static mixed find(mixed $data = null) static 查询单个记录
    • @method static mixed select(mixed $data = null) static 查询多个记录
    • @method static integer insert(array $data, boolean $replace = false, boolean $getLastInsID = false, string $sequence = null) static 插入一条记录
    • @method static integer insertGetId(array $data, boolean $replace = false, string $sequence = null) static 插入一条记录并返回自增ID
    • @method static integer insertAll(array $dataSet) static 插入多条记录
    • @method static integer update(array $data) static 更新记录
    • @method static integer delete(mixed $data = null) static 删除记录
    • @method static boolean chunk(integer $count, callable $callback, string $column = null) static 分块获取数据
    • @method static \Generator cursor(mixed $data = null) static 使用游标查找记录
    • @method static mixed query(string $sql, array $bind = [], boolean $master = false, bool $pdo = false) static SQL查询
    • @method static integer execute(string $sql, array $bind = [], boolean $fetch = false, boolean $getLastInsID = false, string $sequence = null) static SQL执行
    • @method static \think\Paginator paginate(integer $listRows = 15, mixed $simple = null, array $config = []) static 分页查询
    • @method static mixed transaction(callable $callback) static 执行数据库事务
    • @method static void startTrans() static 启动事务
    • @method static void commit() static 用于非自动提交状态下面的查询提交
    • @method static void rollback() static 事务回滚
    • @method static boolean batchQuery(array $sqlArray) static 批处理执行SQL语句
    • @method static string getLastInsID(string $sequence = null) static 获取最近插入的ID

    整合ThinkPHP和Laravel的auth系统不是一个简单的任务,因为两个框架的auth实现方式和设计理念都有所不同。不过,我们可以尝试通过创建中间件来实现这一需求。

    以下是一个基本的示例,演示如何在ThinkPHP中创建一个中间件来检查用户是否已经通过Laravel的auth系统认证:

    在Laravel中,确保已经有一个完整的auth系统,包括用户认证和会话管理。

    在ThinkPHP应用中,创建一个中间件来检查请求中是否存在已认证的用户信息。

    // Laravel应用中创建一个中间件 // 文件路径: app/Http/Middleware/CheckAuth.php

    namespace App\Http\Middleware;

    use Closure; use Illuminate\Support\Facades\Auth;

    class CheckAuth { public function handle($request, Closure $next) { if (Auth::check()) { // 用户已通过认证,可以继续请求 return $next($request); }

        // 用户未认证,可以重定向到Laravel的登录页面或者返回错误信息
        return redirect()->guest('login');
    }

    }

    // 在web.php中注册中间件 // 文件路径: routes/web.php

    Route::group(['middleware' => 'auth'], function () { // 这里定义的路由将会应用 'auth' 中间件 });

    在ThinkPHP中注册中间件,并确保请求能够通过中间件到达Laravel提供的API。

    // ThinkPHP应用中注册中间件 // 文件路径: application/http/middleware.php

    return [ // 其他中间件 'CheckAuth' => \app\http\middleware\CheckAuth::class, ];

    // 在路由中使用中间件 // 文件路径: route/route.php

    Route::group(['middleware' => ['CheckAuth']], function () { // 这里定义的路由将会应用 'CheckAuth' 中间件 });

    请注意,这只是一个基础示例,实际整合时可能需要考虑更多因素,例如会话token的传递、跨域请求的处理等。此外,这种整合方式可能会引入额外的安全问题,确保在实施时考虑充分的安全措施。

    项目简介

    php demo

    发行版本

    当前项目没有发行版本

    贡献者 3

    yuenblue @yuencczzy
    Y yuenblue @yuenblue
    Y yuenblue @yuenblue

    开发语言

    • PHP 100.0 %
    • Shell 0.0 %
    • HTML 0.0 %