【发布时间】:2015-05-10 15:36:43
【问题描述】:
我是 laravel 的新手,并在其中创建了我的第一个控制器,我在目录 app/controllers/ContactController.php 中创建了一个文件,代码是
class ContactController extends BaseController {
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
//
echo "hieeeeeeeeeeeeeeeee";
}
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
//
}
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
//
}
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
//
}
}
但如果我点击 url http://localhost:8000/contact 它会显示错误我们需要一张地图。我错过了什么吗???请帮助我。
更新
我也尝试添加 Route::get('contact', "contact@index");在我的 routes.php 中。
我通过 git-hub 设置了一个用户登录和注册模块,如果我点击 url http://localhost:8000/user/login
,它就可以正常工作更新
我的 laravel 版本是 laravel 4
控制台输出为 39023 Invalid request (Unexpected EOF)
【问题讨论】:
-
你有命名空间吗?
-
请阅读文档。特别是关于控制器和路由:laravel.com/docs/5.0/controllerslaravel.com/docs/5.0/routing
-
@lukasgeiter 我研究过这个但没有效果。
-
为什么-ve???我是说我是新手……
-
那就再研究一下。控制器章节的第三句话说:控制器通常存储在
app/Http/Controllers目录中。你已经没有这样做了。
标签: php laravel controller