Laravel :: 在此服务器上找不到请求的资源 /hello

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41314126/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 14:59:51  来源:igfitidea点击:

Laravel :: The requested resource /hello was not found on this server

phplaravellaravel-5

提问by patipat chewprecha

I got error when I change .php file to .blade.php. Before I changed it got this error.

将 .php 文件更改为 .blade.php 时出现错误。在我改变它之前,它得到了这个错误。

Route::get('hello','HelloController@index');

HelloController

你好控制器

public function index()
    {
      $data = array(
    'name'  => 'Rakesh',
    'email' => '[email protected]');
      return View::make('hello.index')->with('data', $data);
    }

/public/hello/index.blade.php

/public/hello/index.blade.php

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Laravel 5.3 - Home page</title>
  </head>
  <body>
      <h1>Welcome Hello index </h1>
      <h1>{!!$data!!}</h1>
      <h1>{!!$data['email']!!}</h1>
  </body>
</html>

Error

错误

The requested resource /hello was not found on this server.

回答by Matovu Ronald

That error occurs when you create a folder in the public folder with the same name as your route so please change the name of the folder you have put in the public folder so that it has a different name from your route this will probably solve your error

当您在公共文件夹中创建一个与您的路线同名的文件夹时会发生该错误,因此请更改您放入公共文件夹的文件夹的名称,使其与您的路线名称不同,这可能会解决您的错误

回答by Saumini Navaratnam

The view should be inside resources/viewsfolder instead of publicfolder

视图应该在resources/views文件夹内而不是public文件夹内