lumen框架应该怎么使用resource资源路由?
在laravel框架有resource这个方法使用,但在lumen框架中似乎移除了这个方法;一直觉得用resource来规范代码是很不错的。
为了能够让lumen框架使用resource,尝试使用ding go api。ding go api的库里面有resource这个方法。但是使用起来是报错的,报错如下:
(1/1) TypeError
Argument 1 passed to Illuminate\Routing\RouteCollection::add() must be an instance of Illuminate\Routing\Route, null given, called in /home/vagrant/code/lumen_demo/vendor/illuminate/routing/ResourceRegistrar.php on line 99
in RouteCollection.php line 50
at RouteCollection->add(null)
in ResourceRegistrar.php line 99
at ResourceRegistrar->register('demo', 'DemoController', array())
in Router.php line 320
at Router->resource('demo', 'DemoController')
in web.php line 22
at {closure}(object(Router))
at call_user_func(object(Closure), object(Router))
in Router.php line 171
at Router->group(array('namespace' => 'App\\Http\\Controllers', 'version' => array('v1'), 'conditionalRequest' => false, 'prefix' => '/', 'middleware' => array(), 'providers' => array(), 'scopes' => array(), 'before' => array(), 'after' => array(), 'where' => array(), 'domain' => '/'), object(Closure))
in Router.php line 136
at Router->version('v1', array('namespace' => 'App\\Http\\Controllers'), object(Closure))
in web.php line 28
at require('/home/vagrant/code/lumen_demo/routes/web.php')
in app.php line 109
at {closure}(object(Router))
at call_user_func(object(Closure), object(Router))
in Router.php line 62
at Router->group(array('namespace' => 'App\\Http\\Controllers'), object(Closure))
in app.php line 110
at require('/home/vagrant/code/lumen_demo/bootstrap/app.php')
in index.php line 13
请问应该怎么解决呢?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看错误信息
你传了个null,ResourceRegistrar这个在初始化的时候没有传进去Router