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

PHP Introducing MVC Frameworks in PHP Model View Controller Slim MVP

I get an error when running on local machine

The warning shows:

Warning: require(C:\Users\wangr\Desktop\slimtest/../vendor/autoload.php): failed to open stream: No such file or directory in C:\Users\wangr\Desktop\slimtest\index.php on line 6

Fatal error: require(): Failed opening required 'C:\Users\wangr\Desktop\slimtest/../vendor/autoload.php' (include_path='.;C:\php\pear') in C:\Users\wangr\Desktop\slimtest\index.php on line 6

And I cannot access to /hello/name.

I have followed step by step the video, my index.php:

<?php
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Factory\AppFactory;

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

$app = AppFactory::create();

$app->get('/hello/{name}', function (Request $request, Response $response, array $args) {
    $name = $args['name'];
    $response->getBody()->write("Hello, $name");
    return $response;
});

$app->run();

and I do have used command composer install, it seems all packages are duly installed.

Can you help me figure out?

Thanks.