简体   繁体   English

Laravel-导致封锁的路线

[英]Laravel - route leading to a closure

I am not new to MVC, but am new to Laravel. 我不是MVC的新手,而是Laravel的新手。 I have managed to install it on Windows 8.1 with WAMP. 我已经设法在Windows 8.1上使用WAMP安装了它。 I go to the root URL ( http://localhost/public/ ) and get the Laravel logo and the 'You have arrived.' 我转到根URL( http://localhost/public/ )并获得Laravel徽标和“您已经到达”。 line of text. 一行文字。

Now I want to play around a bit, the documentation tells me that the code below should work. 现在,我想尝试一下, 文档告诉我下面的代码应该可以工作。

<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/

Route::get('/', function()
{
    return View::make('hello');
});

Route::get('users', function () {
    return 'users!';
});

I should get the text users when I navigate to http://localhost/public/users instead I get a 404. What am I doing wrong? 导航到http://localhost/public/users users时应该获取文本users ,而不是404。我在做什么错?

Your code in route file should be like this 您的路由文件中的代码应如下所示

Route::get('/users', function () {
    return 'users!';
});

Give it a try! 试试看!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM