Routes of the Slim PHP Framework

6
Hello everyone, I'm having trouble using the Slim framework ... when I try to access via get the root "/" I get it normal, but when I try to access other methods like "/ hello" it simply n goes from the error "Not Found

The requested URL / slim / clients was not found on this server. " not even with the demo this error persists follow my code ...

    <?php
require 'Slim/Slim.php';
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
$app->response()->header('Content-Type', 'application/json;charset=utf-8');


$app->get('/', function () {
echo "SlimProdutos";
});

$app->get('/hello', function (){
    echo "Ola";
});


$app->run();

?> 

follows .htaccess

RewriteEngine On
#RewriteBase /var/www/slim

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]

    
asked by anonymous 30.01.2015 / 03:26

1 answer

2

Good morning.

I do not have much experience with Slim, but the way I've done it and it worked like this:

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

My .htaccess, looks like this:

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.*)$ %{ENV:BASE}index.php [QSA,L]

I hope I have helped.

    
17.03.2015 / 12:21