我有这个代码,但我的方法找不到?
Route.php
Route::controller('Basic', 'BasicController');
BasicController.php
class BasicController extends BaseController {
public function getIndex()
{
return View::make('hello');
}
public function getTest()
{
return 'test';
}
}
当我从浏览器调用测试时:`http://mydomain.dev/Basic/Test不工作!
并得到此错误:
Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException
未找到控制器方法[测试]。
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.");
}
为什么?
我的laravel版本是4.1.8
答案 0 :(得分:4)
如果你执行
artisan 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 | | |
如果您说您的索引有效:
所以你需要点击路线
http://mydomain.dev/Basic/test
和不
http://mydomain.dev/Basic/Test