thinkphp 报错 think service:discover 255

756 阅读1分钟

windows 环境:

image.png

> @php think service:discover  
Script @php think service:discover handling the post-autoload-dump event returned with error code 255

网上有很多的解决方案,但是都不一样,说明问题也不一样。 所以关键点 怎么定位问题

  1. 有打断点的 xdbug 可以看我的这篇 Xdebug3 Windows Phpstorm2023 使用Postman发送请求篇幅分: xdebug的安装和配置 - 掘金 (juejin.cn)

  2. 日志打印(推荐), 配置日志输出 php.ini 中

error_log = "D:\Program11\PHPBtSoft\php\php_error.log"

image.png

记录下我的问题: 初始化顺序的问题,config中的文件要用到初始化常量,但是初始化文件没有成功

// config 的某个文件头部,添加引入公共入口文件
// 做了一个判断
if (!defined('ROOT')) {
    require __DIR__ . '/../public/core.php';
}