View index not found Laravel Error Message

Posted on

This is an article where an error generated accessing a part of URL named ‘test’. The full URL is shown below :

http://localhost/public/test

Using an already defined route for using a resource from a controller named ‘TestController’ by the following line added in a file named web.php in folder routes :

Route:resource('test','TestController');

The next part is just create a method named ‘index()’ in the already created controller through the following process and it is executed in the bash prompt:

user@hostname:~$ php artisan make:controller TestController

But to be able to return or to display the right view, it needs to be defined and created first. The one which is needed to be defined is the target of the view which is returned by the controller as shown below :

public function index(){

     return view('index');

}

But in the end, it is still generating an error as shown below :

View [index] not found.

But whenever the snippet code is changed into the following :

public function index(){

     return view('test');

}

The main purpose is just to accessed any index blade view file inside a folder named ‘test’ which is located in a folder named ‘resources/views’ and it is still displaying the same result. An error but different message and the error message is ‘View [test] not found.’

The following is the error message displayed in a image :

So, to solve this problem, there is a modification to the snippet code given above. It is changing the return value in the file named TestController.php, specifically in a method named ‘index()’ as follows :

public function index(){

     return view('test.index');

}

So, the page will be displayed as follows :

View index not found Laravel Error Message
View index not found Laravel Error Message

This is the content of a file named index.blade.php located in a folder named ‘resources/views/test’. The content is still not in a well arranged position because the bootstrap responsible for arranging it cannot be found. So basically the problem has been solved for displaying the file located in resources/views.

One thought on “View index not found Laravel Error Message

Leave a Reply