user2417713
user2417713

Reputation: 167

Laravel 5 blank page view

Started working through a very basic Laravel 5 tuturial, after installing a thresh laravel installation via composer, and experienced the following problem. Having created an about view 'resources/views/about.blade.php', I only get a blank page displayed.

The strange thing is, having played around with the welcome page, to try and isolate the problem, it turns out that I can only view the welcome page if its name is welcome.

routes.php code:

Route::get('about', 'PagesController@about');

PagesController.php code:

<?php
namespace App\Http\Controllers;

class PagesController extends Controller {

    public function about() {
        return view('welcome');
    }
}

This displays the 'resources/views/welcome.blade.php' file prefectly. However, if I rename it to anything else eg. 'resources/views/test.blade.php', and change the return view in the controller accordingly:

return view('test');

I just get a blank page. What's the problem?

Upvotes: 0

Views: 728

Answers (2)

user2417713
user2417713

Reputation: 167

The problem turns out to be the URL. Following the Laracast tutorials (Laravel 5 Fundamentals), I started the server using the following command:

php -S localhost:8888 -t ~/Desktop/html/learning-laravel-5/public

This results in the following Laravel project's root address: http://localhost:8888

Consequently, http://localhost:8888/about equates to the about page. However, I ended up using the following address:

localhost/learning-laravel-5/public/about

This results in a blank page if I haven't already viewed the page via http://localhost:8888/about

Upvotes: 0

Sulthan Allaudeen
Sulthan Allaudeen

Reputation: 11310

I guess your problems should be this,

Problem :

You would not configured your .htaccess to point your application directly

What should you do

You should make your call to the application absolutely

How

Do you call like this

http://yourapplication.com/public/index.php/about

If you want to access it like

http://yourapplication.com/about

then you should configure .htaccess to make it done (Let me know if you need this)

Note :

  1. Make sure that you enable error_reporting in your server

  2. Make sure that you output something in your blade

Upvotes: 0

Related Questions