0

I am probably miss something, but can't figure out problem myself.

I am getting white screen (no logs in storage/logs and 200 code in Apache logs). I think that return View::make() is not passing view string.

In routes.php

Route::get('/home', array('as' => 'home', 'uses' => 'HomeController@index'))->before('guest');

In filters.php

Route::filter('guest', function(){
if (Auth::check() === true) {
    return Redirect::route('dashboard')->with('flash_notice', 'You are already logged in!');
}});

In HomeController.php

class HomeController extends BaseController {
public function index()
{
    return View::make('login');
}}

In views/login.blade.php

@extends('layouts.login')

In views/layouts/login.blade.php just HTML

Once I change return View::make('login'); to echo View::make('login'); I get rendered view.

I did install same codebase previously and it worked (yes, it was Laravel 4 as well), so I wonder this somehow related to new library versions.

Thank you for your help.

4
  • Do you have a $layout property configured in your BaseController? Commented Dec 30, 2013 at 15:37
  • @petkostas I don't. Should I manually configure it? In BaseControll I have only protected function setupLayout() { if (is_null($this->layout)) { $this->layout = View::make($this->layout); } } And layout is null. Commented Dec 30, 2013 at 16:02
  • Can you paste your login.blade.php file? Commented Dec 30, 2013 at 16:11
  • link When I put die() before closing html tag I see rendered view. Commented Dec 30, 2013 at 16:26

2 Answers 2

1

Create a master file base.blade.php inside your views/layouts folder:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<title>Signin</title>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>

<style>
  body {
      background-color: #EEEEEE;
      padding-bottom: 40px;
      padding-top: 40px;
  }
  .form-signin {
      margin: 0 auto;
      max-width: 330px;
      padding: 15px;
  }
  .form-signin .form-signin-heading, .form-signin .checkbox {
      margin-bottom: 10px;
  }
</style>
</head>

<body>
<div class="container">
@section('maincontent')
@show
</div>
</body>
</html>

And then in your login.blade.php:

@extends('layouts.base')
@section('maincontent')
<form class="form-signin" action="/login" method="POST" >
    @if ($errors->first('login'))
        <div class="alert alert-danger" >
            {{$errors->first('login')}}
        </div>
    @endif
    @if ($errors->first('password'))
        <div class="alert alert-danger" >
            {{$errors->first('password')}}
        </div>
    @endif
    @if(Session::has('flash_notice'))
        <div class="alert alert-danger" >
            {{Session::get('flash_notice')}}
        </div>
    @endif
    @if(Session::has('flash_success'))
        <div class="alert alert-success" >
            {{Session::get('flash_success')}}
        </div>
    @endif
    <h2 class="form-signin-heading">Please sign in</h2>
    <input type="text" class="form-control" placeholder="Login" name="login" autofocus>
    <input type="password" class="form-control" placeholder="Password" name="password" >
    <label class="checkbox"></label>
    <button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
  </form>
  @stop
Sign up to request clarification or add additional context in comments.

5 Comments

I tried both cases: with *.php and *.html and still no luck. If that helpful I got 2 files generated in app/storage/views/ link
Sorry it was my mistake it should be blade.php the extension
Don't worry =) Wonder why Laravel does not render those views. Since I change return to echo and they are rendered, probably problem is not in the view itself? Maybe some Parent Class which responsible for rendering is not doing it's job? Can I use echo in every controller instead?
After more deep debugging I figured out that problem is related to upgrade from Laravel 4.0 to version 4.1 To be more specific: "Undefined index: expire_on_close". I just added 'expire_on_close' => false, to app/config/session.php Thank you for your help!
You are welcome, glad to see you found the problem :)
0

Change Route:

Route::get('home', array('as' => 'home', 'before' => 'guest', 'uses' => 'HomeController@index'));

5 Comments

Same result. Looks like problem is in the View/Controller.
Try installing debugbar and make a check of what is returned and if the request if ok.
I even got "compiled" view in app/storage/views: <?php echo $__env->make('layouts.login', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?> I wonder why switch return View::make('login'); to echo View::make('login'); in controller does the trick.
Was the code in the link you provided your actual template? If yes then your template is wrong and that is why it's not working, you need to create a layout and extend the login from there:
Code in the link is sitting at app/views/layouts/login.blade.php Template is app/views/login.blade.php and has only one line with no spaces: @extends('layouts.login')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.