Routes not working on Slim framework

Viewed 1395

I am learning the slim framework. I got a point where I have to set up my webserver such that I can see something like http://slimapp instead of http://localhost/slimapp/public/index.php.

I have included a .htaccess file in the public folder of my project like so

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]

I have also set up a virtual host on my wamp server

<VirtualHost *:80>
    DocumentRoot "C:\wamp64\www\slimapp\public"
    ServerName slimapp

    <Directory "C:\wamp64\www\slimapp\public">
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

I have also added this to my hosts file

127.0.0.1 slimapp 

I restarted my server but I get a 'Not Found' error when I try to access my routes.

"Not Found
The requested URL /hello/uche was not found on this server."

This is my index.php file

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

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

$app = new \Slim\App;
$app->get('/hello/{name}', function (Request $request, Response $response) {
    $name = $request->getAttribute('name');
    $response->getBody()->write("Hello, $name");

    return $response;
});
$app->run();

Please help me here.

2 Answers
Related