Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Adam Siwiec
Adam Siwiec
12,070 Points

Help with Slim, Twig, and PHP, in my project.

I'm currently working on a redesigning my website with PHP, currently I have a rough sketch laid out. The only problem is I'm try to D.R.Y why code with PHP and Twig templates, but whenever I run it on my local server it never fully runs. I know everything on my computer and server is fine because I have run my project from workspaces on it and it worked. All my software (used in my working and failing projects) is up to date and I ran my localhost in chrome. Can anyone take a look at my source code and tell me if there is anything wrong with it?


require __DIR__ .'/vendor/autoload.php';

$app = new \Slim\Slim( array(
  'view' => new \Slim\Views\Twig()

 $view = $app->view();
$view->parserOptions = array(
    'debug' => true
$view->parserExtensions = array(
    new \Slim\Views\TwigExtension(),

$app->get('/', function() use($app){

$app->get('/case', function() use($app){

$app->get('/me', function() use($app){

$app->get('/video', function() use($app){


main.twig :

<!DOCTYPE html> 
    <meta charset= "utf-8">
    <title> Adam Siwiec</title>   
    <link rel="stylesheet" href="css/style.css"> 
    <link href='https://fonts.googleapis.com/css?family=Roboto|Montserrat' rel='stylesheet' type='text/css'> 

            <section class = "title">
            <a href="index.html" >
            <h1>Adam Siwiec</h1>
                Interestingly Complementary

                <ul id = "navigation">
                    <li><a href="me.html">Vision</a></li>
                    <li><a href="vid.html">Library</a></li>
                    <li><a href="case.html">Cases</a></li>


        {%block content%}
        {%endblock content%}


         <p> Adam Siwiec 2016 </p>




I have a couple more "content" pages that inputs content to main.twig, but there is nothing wrong with them.

1 Answer

Maybe you should check Slim User Gide to ensure that you start you server correctly and give to it proper file.