我有一个工作laravel安装,我想添加一个路由,但它不起作用。
Route::get('asdf', function() {return "asdf";});
所有其他路线都有效,但新路线不起作用,甚至不是控制路线。我刚刚尝试简化上面的示例,在此发布。
composer install
php artisan dump-autoload
php artisan serve --port 80
服务器控制台报告此错误:
[Fri Jul 12 10:11:11 2013] 127.0.0.1:51042 Invalid request (Unexpected EOF)
[Fri Jul 12 10:11:11 2013] 127.0.0.1:51043 Invalid request (Unexpected EOF)
[Fri Jul 12 10:11:11 2013] 127.0.0.1:51044 Invalid request (Unexpected EOF)
以下是日志。
感谢。
[2013-07-12 08:29:44] log.ERROR: exception 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException' in C:\xampp\htdocs\lv\laravella\vendor\laravel\framework\src\Illuminate\Routing\Controllers\Controller.php:290
Stack trace:
#0 [internal function]: Illuminate\Routing\Controllers\Controller->missingMethod(Array)
#1 C:\xampp\htdocs\lv\laravella\vendor\laravel\framework\src\Illuminate\Routing\Controllers\Controller.php(138): call_user_func_array(Array, Array)
#2 C:\xampp\htdocs\lv\laravella\vendor\laravel\framework\src\Illuminate\Routing\Controllers\Controller.php(115): Illuminate\Routing\Controllers\Controller->callMethod('missingMethod', Array)
#3 C:\xampp\htdocs\lv\laravella\bootstrap\compiled.php(4741): Illuminate\Routing\Controllers\Controller->callAction(Object(Illuminate\Foundation\Application), Object(Illuminate\Routing\Router), 'missingMethod', Array)
#4 [internal function]: Illuminate\Routing\Router->Illuminate\Routing\{closure}(Array)
#5 C:\xampp\htdocs\lv\laravella\bootstrap\compiled.php(7810): call_user_func_array(Object(Closure), Array)
#6 C:\xampp\htdocs\lv\laravella\bootstrap\compiled.php(7797): Illuminate\Routing\Route->callCallable()
#7 C:\xampp\htdocs\lv\laravella\bootstrap\compiled.php(4752): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request))
#8 C:\xampp\htdocs\lv\laravella\bootstrap\compiled.php(480): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#9 C:\xampp\htdocs\lv\laravella\bootstrap\compiled.php(469): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request))
#10 C:\xampp\htdocs\lv\laravella\public\index.php(49): Illuminate\Foundation\Application->run()
#11 C:\xampp\htdocs\lv\laravella\server.php(19): require_once('C:\xampp\htdocs...')
#12 {main} [] []
答案 0 :(得分:1)
如果你有任何控制器路由,请确保Route::get('asdf', function() {return "asdf";});
高于控制器路由,因为控制器路由是贪婪的,他们不会让Route::get()
处理它们应该拥有的路由。
编辑查看您的github克隆routes.php
,如
Route::controller('account', 'AccountController');
Route::controller('/', 'HomeController');
Route::get('asdf', function() {return "asdf";});
所以为了使你的Route::get('asdf','...');
能够正常工作,只需将它添加到控制器路径ex -
Route::get('asdf', function() {return "asdf";});
Route::controller('account', 'AccountController');
Route::controller('/', 'HomeController');
它会起作用