I study fine structure. I have a point where I have to configure my web server so that I can see something like http: // slimapp instead of http: //localhost/slimapp/public/index.php .
I included the .htaccess file in the public folder of my project so
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
I also created 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 also added this to my hosts file
127.0.0.1 slimapp
I restarted my server, but when I tried to access my routes, I received a "Not Found" error.
"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.
source
share