看了一下源码,lumen 没办法支持 Laravel 中的这种写法,不过可以扩展一下,编辑一下 bootstrap/app.php 里面,有关 `$app` 这个变量初始化的地方,改成下面这样。 $app = new class (dirname(__DIR__)) extends Laravel\Lumen\Application { protected function callActionOnArrayBasedRoute($routeInfo) { $action = $routeInfo[1]['target'] ?? $routeInfo[1]; if ( is_array($action) && count($action) === 2 && class_exists($action[0]) && method_exists($action[0], $action[1]) ) { try { [$controller, $method] = $action; return $this->prepareResponse($this->call([$this->make($controller), $method], $routeInfo[2])); } catch (HttpResponseException $e) { return $e->getResponse(); } } return parent::callActionOnArrayBasedRoute($routeInfo); } }; (注:这段代码是我手敲的,未做完整测试) 然后就可以像下面这样使用了,并且 IDE 可以提示跳转。 $router->get('/foo', [ 'target' => [\App\Http\Controllers\ExampleController::class, 'index'] ]); $router->get('/foo', [\App\Http\Controllers\ExampleController::class, 'index']); 在旧版的 PhpStorm 上,这样可能还是不可以跳转,因为 `\Laravel\Lumen\Routing\Router::get` 方法的第二个参数的签名是 `mixed` 类型的,并不是 `callback`,所以 IDE 可能还是无法识别。 可能还需要添加一个提示文件(在 laravel-ide-helper 里面加一下也可以)。 * * * 当然,如果你只需要提示+跳转的话,还有一个办法,那就是发动钞能力,PhpStorm 有个 [Laravel Idea](https://link.segmentfault.com/?enc=5cLuEA6DvRZVAYz82mEU3w%3D%3D.vtzOQc2UFlTI5cNy1Mkd7%2BYn2rtPKOOECVgFcifw6so%3D) 是可以的,不过这是一个付费插件,3$/mo * * * 另外,不太建议使用 lumen 作为新项目,因为项目复杂了之后,都会变成 Laravel 的形状。