I have a project in laravel5 and I have directed virtual host on /public directory. Where should be my main page index.php now? There is some index.php in public folder already but it contains some content that I dont understand. So where should be my index now? Maybe in views?
索引文件位于同一位置,可以使用HTML来调用您创建的新文件,您可以将该文件放在视图中并从控制器调用它,希望这是您要寻找的答案。
If you are using Laravel 5.1 then your initial page should be this resources/views/welcome.blade.php
.
You can change it to any name. But also you should change the same in your Controller
.
Note : If you are rendering the view through controller then you should have the file name like this yourfilename.blade.php
Your views should always inside resources/views/*
When a request come to your server, the first file that it is executed is index.php
. But this is not the file shown. In Laravel you don't have to force any file be named index.php
. So let's imagine that you are trying set up a new index file. You have to use routes.php
routes.php
Route::get("/" , "HomeController@index");
HomeController.php
function index(){
return view("home/index");
}
views/home/index.blade.php
<html>
<head>
</head>
<body>
<p>Index page</p>
</body>
</html>
When a GET
request to "/"
it's done, the index
function of the HomeController
it's executed and the view index.blade.php
, stored in views/home
it's shown.
This it's the basic behaviour of Laravel. So you mustn't rename or move the index.php
file in public
folder.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.