divHelper11
divHelper11

Reputation: 2208

Laravel framework index.php

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?

Upvotes: 2

Views: 6154

Answers (3)

Luis González
Luis González

Reputation: 3559

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.

Upvotes: 1

Sulthan Allaudeen
Sulthan Allaudeen

Reputation: 11310

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/*

Upvotes: 2

XAF
XAF

Reputation: 1472

The index file stays at the same place, to call a new file that you made, could be with HTML, you can put that file in the view and call it from the controller, hope this is the answer you are looking for.

Upvotes: 1

Related Questions