1.lumen Controllers結構
Controllers --Test --TestController.php
2.註冊路由
$app->get("test",'Test\TestController@est');
3.lumen報錯;
lumen.ERROR: ReflectionException: Class App\Http\Controllers\Test\TestController does not exist in /Users/shumingjian/Desktop/www/lumen/vendor/illuminate/container/Container.php:734
4.Testcontroller代碼:
namespace AppHttpControllersTest;
use AppHttpControllersController as Controller;
class TestController extends Controller
{
public function test(){ echo 1132;}
}
?>
該代碼在Controllers下可以正常輸出,但在ControllersTest檔案夾下異常
lumen 版本 5.2.9
回複內容:
1.lumen Controllers結構
Controllers --Test --TestController.php
2.註冊路由
$app->get("test",'Test\TestController@est');
3.lumen報錯;
lumen.ERROR: ReflectionException: Class App\Http\Controllers\Test\TestController does not exist in /Users/shumingjian/Desktop/www/lumen/vendor/illuminate/container/Container.php:734
4.Testcontroller代碼:
namespace AppHttpControllersTest;
use AppHttpControllersController as Controller;
class TestController extends Controller
{
public function test(){ echo 1132;}
}
?>
該代碼在Controllers下可以正常輸出,但在ControllersTest檔案夾下異常
lumen 版本 5.2.9
看起來是找不到 AppHttpControllersTestTestController 這個類,路由定義是沒錯的,應該是類載入的問題。
你試著運行 php artisan tinker,然後在 shell 裡運行 $foo = new App\Http\Controllers\Test\TestController; 看看能不能找到這個類。