laravel 4.1 控制器方法......未找到
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20617244/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
laravel 4.1 Controller method .... not found
提问by Mohammad
i have this code but my Method not find ?
我有这个代码,但我的方法没有找到?
Route.php
路由.php
Route::controller('Basic', 'BasicController');
BasicController.php
基本控制器.php
class BasicController extends BaseController {
public function getIndex()
{
return View::make('hello');
}
public function getTest()
{
return 'test';
}
}
when i call test from browser : `http://mydomain.dev/Basic/TestNot Work !
and get this error :
当我从浏览器调用测试时:` http://mydomain.dev/Basic/Test不工作!
并收到此错误:
Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException
Controller method [Test] not found.
Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException
控制器方法 [Test] 未找到。
open: /var/www/mydomain.dev/vendor/laravel/framework/src/Illuminate/Routing/Controller.php
* @param array $parameters
* @return mixed
*
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
*/
public function missingMethod($method, $parameters = array())
{
throw new NotFoundHttpException("Controller method [{$method}] not found.");
}
Why ?
为什么 ?
My laravel version is 4.1.8
我的 Laravel 版本是 4.1.8
回答by Antonio Carlos Ribeiro
If you execute
如果你执行
artisan routes
You probably will see those routes
你可能会看到那些路线
+--------+--------------------------------------------------------+------------+--------------------------------+----------------+---------------+
| Domain | URI | Name | Action | Before Filters | After Filters |
+--------+--------------------------------------------------------+------------+--------------------------------+----------------+---------------+
| | GET Basic/index/{one?}/{two?}/{three?}/{four?}/{five?} | | BasicController@getIndex | | |
| | GET Basic | | BasicController@getIndex | | |
| | GET Basic/test/{one?}/{two?}/{three?}/{four?}/{five?} | | BasicController@getTest | | |
| | GET Basic/{_missing} | | BasicController@missingMethod | | |
| | GET test | | Closure | | |
If you say that your index is working:
如果您说您的索引正在运行:
So you need hit the route
所以你需要点击路线
http://mydomain.dev/Basic/test
and not
而不是
http://mydomain.dev/Basic/Test