# public/index.php
<?php
require '../vendor/autoload.php';
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;
$app = new \Slim\App;
$app->get('/user/{name}', function (Request $request, Response $response) {
$name = $request->getAttribute('name');
$response->getBody()->write("Hello, $name");
return $response;
});
$app->run();
server {
listen 80;
server_name slim.my;
root /Users/akio/develop/slim/public/;
access_log /Applications/MxSrvs/logs/slim.access.log;
error_log /Applications/MxSrvs/logs/slim.error.log;
index index.php index.html index.htm;
#limit_conn one 10;
if (!-e $request_filename){
rewrite ^(.*)$ /index.php break;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass 127.0.0.1:10080;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
或
cd public
php -S localhost:8080
http://localhost:8080/user/akio
或
slim.my/user/akio