请问 Lumen 设置route的时候为什么不好使呢

[2015-04-17 07:03:41] lumen.ERROR: exception 'ReflectionException' with message 'Class HomeController does not exist' in /Users/refear99/Web/qingsongchou_api/vendor/illuminate/container/Container.php:776
Stack trace:

0 /Users/refear99/Web/qingsongchou_api/vendor/illuminate/container/Container.php(776): ReflectionClass->__construct('HomeController')

1 /Users/refear99/Web/qingsongchou_api/vendor/illuminate/container/Container.php(656): Illuminate\Container\Container->build('HomeController', Array)

2 /Users/refear99/Web/qingsongchou_api/vendor/laravel/lumen-framework/src/Application.php(358): Illuminate\Container\Container->make('HomeController', Array)

3 /Users/refear99/Web/qingsongchou_api/vendor/laravel/lumen-framework/src/Application.php(1184): Laravel\Lumen\Application->make('HomeController')

4 /Users/refear99/Web/qingsongchou_api/vendor/laravel/lumen-framework/src/Application.php(1157): Laravel\Lumen\Application->callControllerAction(Array)

5 /Users/refear99/Web/qingsongchou_api/vendor/laravel/lumen-framework/src/Application.php(1142): Laravel\Lumen\Application->callActionOnArrayBasedRoute(Array)

6 /Users/refear99/Web/qingsongchou_api/vendor/laravel/lumen-framework/src/Application.php(1120): Laravel\Lumen\Application->handleArrayBasedFoundRoute(Array)

7 /Users/refear99/Web/qingsongchou_api/vendor/laravel/lumen-framework/src/Application.php(1058): Laravel\Lumen\Application->handleFoundRoute(Array)

8 /Users/refear99/Web/qingsongchou_api/vendor/laravel/lumen-framework/src/Application.php(1006): Laravel\Lumen\Application->dispatch(NULL)

9 /Users/refear99/Web/qingsongchou_api/public/index.php(28): Laravel\Lumen\Application->run()

10 {main}



这是我的route
$app->get('/', 'HomeController@index');

我的HomeController
<?php namespace App\Http\Controllers;

class HomeController extends Controller {

public function index()
{
    echo 123;
}

}
已邀请:

MASK

赞同来自: 雨师 refear99

$app->group(['namespace'=>'\App\Http\Controllers'],function($group){
$group->get('/','......');
$group->get('....','......');
});

shirne

赞同来自:

我试了下,
$app->get('/', 'App\Http\Controller\HomeController@index');
可以,但是不知道怎么能简化。

雨师

赞同来自:

没有写默认的命名空间,应该这也是“压缩版”和“正常版”的不同吧

w407586321

赞同来自:

修改bootstrap/app.php如下:
// require __DIR__.'/../app/Http/routes.php';
$app->group(['namespace' => 'App\Http\Controllers'], function ($app) {
require __DIR__.'/../app/Http/routes.php';
});

要回复问题请先登录注册