【发布时间】:2015-02-05 21:38:36
【问题描述】:
我使用此代码,服务器响应时间约为 500-700 毫秒。如果写'return;'将 Slim 对象创建为 $app 后,响应时间约为 200-250 毫秒。为什么这个框架工作很慢?能不能快点?
require 'Slim/Slim.php';
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim(array(
'debug' => true,
'templates.path' => './templates'
));
$headerType = $app->request->headers->get('Accept');
switch($headerType){
case "text/html":
$app->response->headers->set("Content-Type",'application/xml');
echo $headerType;
break;
case "application/xml":
echo $headerType;
$app->response->headers->set("Content-Type",'application/xml');
break;
case 'application/json':
default:
$app->response->headers->set("Content-Type",'application/json; charset=utf-8');
}
$app->get('/modules/:id', function ($id) {
echo Modules::getJsonModule($id);
});
$app->get('/countries/:id', function ($id) {
echo CountriesControls::getJsonCountry($id);
});
$app->get('/modules/:id/childs', function ($id) {
echo Modules::getJsonChilds($id);
});
$app->get('/', function () {
});
$app->get('/modules/:id/summary', function ($id) {
});
$app->run();
【问题讨论】: