原本以为是很简单的一个用法。
action('XxxxController@test',['abc'=>1]);
结果,不仅仅是这样的,
如果你的XxxxController@test,没有在router里定义过。会直接报错,报:App\Http\Controller\XxxController@test 不存在,虽然 你很明确的知道它就在那里!
原来我 写URL的时候都是直接写 url('abc/def'),其实应该用action('xxxcontroller@def'),好处是,action是可以带参数的。url你永远带不进参数!!!
纯记录。NND
Lumen在初次安装好启动的时候,访问会出现:NotFoundHttpException
找了一下原因,在stackoverflow上有很多人提出来。常见的有这两种:在public/index.php里修改最后的$app->run();
- $app->run($app->make('request'));
- $app->run(Illuminate\Http\Request::capture());
如果用第1种,那你会发现所有的路由都被"/"解析了。你随便在URL里输入啥,都只会进入$app->get("/")这个路由
只有第二种才是正确的。
记录一下,参考 :
1、http://stackoverflow.com/questions/29728973/notfoundhttpexception-with-lumen
2、http://stackoverflow.com/questions/36436967/just-installed-lumen-and-got-notfoundhttpexception