【发布时间】:2015-01-11 04:52:56
【问题描述】:
我刚开始构建一个 Laravel 应用程序,遇到了路由问题。
- Laravel 版本 - 4.2
- PHP 版本 - 5.5
- 我正在使用 XAMPP
- 我在 Apache 上启用了重写模块
这是我的路线文件:
<?php
Route::get('/', array(
'as' => 'index',
'uses' => 'IndexController@index'
));
Route::get('/account', array(
'as' => 'account',
'uses' => 'AccountController@get_create'
));
我的控制器如下所示:
<?php
class IndexController extends BaseController
{
public function index()
{
return View::make('index');
}
}
<?php
class AccountController extends BaseController
{
public function get_create()
{
return 'asd';
}
public function post_create()
{
}
}
这是我的错误:
Symfony\Component\HttpKernel\Exception\NotFoundHttpException thrown with message ""
Stacktrace:
#11 Symfony\Component\HttpKernel\Exception\NotFoundHttpException in C:\xampp\htdocs\Protosite\bootstrap\compiled.php:5680
#10 Illuminate\Routing\RouteCollection:match in C:\xampp\htdocs\Protosite\bootstrap\compiled.php:5004
#9 Illuminate\Routing\Router:findRoute in C:\xampp\htdocs\Protosite\bootstrap\compiled.php:4992
#8 Illuminate\Routing\Router:dispatchToRoute in C:\xampp\htdocs\Protosite\bootstrap\compiled.php:4984
#7 Illuminate\Routing\Router:dispatch in C:\xampp\htdocs\Protosite\bootstrap\compiled.php:715
#6 Illuminate\Foundation\Application:dispatch in C:\xampp\htdocs\Protosite\bootstrap\compiled.php:696
#5 Illuminate\Foundation\Application:handle in C:\xampp\htdocs\Protosite\bootstrap\compiled.php:7744
#4 Illuminate\Session\Middleware:handle in C:\xampp\htdocs\Protosite\bootstrap\compiled.php:8351
#3 Illuminate\Cookie\Queue:handle in C:\xampp\htdocs\Protosite\bootstrap\compiled.php:8298
#2 Illuminate\Cookie\Guard:handle in C:\xampp\htdocs\Protosite\bootstrap\compiled.php:10961
#1 Stack\StackedHttpKernel:handle in C:\xampp\htdocs\Protosite\bootstrap\compiled.php:657
#0 Illuminate\Foundation\Application:run in C:\xampp\htdocs\Protosite\public\index.php:49
编辑:我忘了提一件事,索引工作正常,它是有错误的帐户页面。
我看过类似的问题,但由于某种原因他们没有解决。
干杯!
【问题讨论】:
-
你应该删除
/account前面的斜线,这在 Laravel 中是不需要的。