ousaa / think-ide-helper
Package info
gitlab.seastt.com/ousaa/php-packages/think-ide-helper
pkg:composer/ousaa/think-ide-helper
v2.0.1
2026-05-16 10:26 UTC
Requires
- ergebnis/classy: ^1.1
- phpdocumentor/reflection-docblock: ^5.4
- topthink/framework: ^8.0
- topthink/think-orm: ^4.0
README
为 ThinkPHP 模型自动生成 IDE 提示注释(@property、@property-read、@method),让 IDE 能正确提示模型属性和关联方法。
版本说明
| 版本系列 | 分支 | 支持框架 | PHP 版本 |
|---|---|---|---|
v0.*.* | tp51 | ThinkPHP 5.1.x | PHP 7.4+ |
v1.*.*(及以上) | master | ThinkPHP 8.x + think-orm 4.x | PHP 8.0+ |
安装
ThinkPHP 8.x(v1.. 及以上版本)
composer require ousaa/think-ide-helper
ThinkPHP 5.1.x(v0.. 版本)
composer require ousaa/think-ide-helper:^0.1
或安装开发分支:
composer require ousaa/think-ide-helper:dev-tp51
安装后,包会自动将命令注册配置文件复制到项目 config/ide-helper.php。若使用 path 本地路径安装(symlink),需手动创建该配置文件。
使用
1. 模型注释
# 扫描所有模型(默认 app/model 目录)
php think ide-helper:model
# 指定模型
php think ide-helper:model app\\model\\User app\\model\\Post
可选参数
--dir="models" [-D] 指定搜索目录(相对于应用基础目录),可多次指定,默认为 app/model
--ignore="app\\model\\User,app\\model\\Post" [-I] 忽略的模型,逗号分隔
--overwrite [-O] 强制覆盖已有的属性注释
--reset [-R] 重置模型的所有注释
tp51(v0..)与 master(v1..)的差异
| 功能 | master (TP8) | tp51 (TP5.1) |
|---|---|---|
| 字段注释(COMMENT) | 支持 | 仅 MySQL 支持 |
| HasOneThrough 关联 | 支持 | 不支持(TP5.1 框架无此关联) |
| MorphToMany 关联 | 支持 | 不支持(TP5.1 框架无此关联) |
| 扩展钩子 | Event 系统 | Hook 系统 |