Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP Building Websites with PHP Slim Basics & Twig Templates Layouts with Twig

Juliette Tworsey
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Juliette Tworsey
Front End Web Development Techdegree Graduate 32,413 Points

White screen of death-

I'm lost. If anyone could help that would be awesome!

Thanks-

main.twig:

<!doctype html>

<html lang="en"> <head> {% block head %} <meta charset="utf-8"> <title> {% block title %}Ralph Waldo Emerson {% endblock title %}</title> <meta name="description" content="Ralph Waldo Emerson"> <meta name="author" content="Treehouse"> <link href='http://fonts.googleapis.com/css?family=Roboto:400,700' rel='stylesheet' type='text/css'> <link rel="stylesheet" href="css/master.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script src="js/global.js"></script> {% endblock head %} </head>

<body> <!-- <div id="feedback" class="success"> <h3>Success!</h3> <p>You're reading all about Emerson.</p> </div> -->

<header> <h1>Ralph Waldo Emerson</h1> <nav> <a href="index.html" class="selected">About</a> <a href="contact.html">Contact</a> </nav> </header>

<div class="emerson"> {% block hero %} <img src="images/emerson.jpg" alt="Picture of Ralph Waldo Emerson"> {% endblock hero %} </div>

<main> {% block content %}

 {% endblock content %}

</main>

<footer> {% block footer %} <p>A project from <strong><a href="http://teamtreehouse.com">Treehouse</a></strong></p> <nav> <a href="index.html" class="selected">About</a> <a href="contact.html">Contact</a> </nav> {% endblock footer %} </footer>

</body> </html>

Can you post a fork snapshot link?

On the upper right side of the Workspace are three buttons. One of those is fork snapshot. Click that and it will give you a link. You may have to open the link, but you may be able to right click and copy link. Either way, paste the link here.

I think you loaded the fork, not the fork snapshot. You have to click the camera icon, then either copy the link in the window or click the link and copy the url from the new browser window.

Yes, that worked. I may not have time to find the reason this morning.

2 Answers

Solved! In addition to the errors listed above, there are two extra semicolons:

<?php
$app = new \Slim\Slim(array(
      'view' => new \Slim\Views\Twig()  // no semicolon

));

$view = $app->view();
$view->parserOptions = array(
    'debug' => true // no semicolon
);

I used the live preview function in the free text editor Brackets. It gave me line numbers for the errors and what it thought the issue was.

Making progress, but not completely solved.

  1. You did not install slim/view. Enter composer require in the console. Then enter slim. It should be number 1 (the second entry.)

  2. Your $app = new \Slim\Slim line has the parentheses in the wrong place. It should be $app = new \Slim\Slim(array(

  3. You send the router to index.html, but it does not exist. It should be about.twig. BUT, this is not the problem. You would get Slim errors, not the white screen of death.

  4. You do not have ->name('home') after your render command. Again, this is not your core problem. Slim is not running from your commands. I copied my functioning code from this program and it ran properly, so the installation is working after the slim\views installation.

  5. If you put echo lines throughout your code, you will find that they stop displaying as soon as you try to call slim.

I will try some more troubleshooting, but I am not sure what else I will find. I tried to go line by line and copied valid code to check and it worked. One person had a problem where a character looked like a hash (#) but was actually a different character, which screwed up the code and was impossible to see.