在slim框架上使用Web服务时出现错误404

时间:2015-03-19 18:59:35

标签: php web-services slim

如果我使用此方法使用此reour http://localhost/esi3d/它可以正常工作

$app->get(
"/", function () use($app){
    $db = new Db_handler;
    $result = $db->select_all("clase");

    while($row = $result->fetch_assoc()){
        $dependency[] = $row ;
    }
    $struct = array("Dependencies"=>$dependency);

    $app->response->headers->set("Content-type","application/json");
    $app->response->status(200);
    $app->response->body(json_encode($struct));
}
);

但如果我尝试使用参数,则使用该路由http://localhost/esi3d/clase会出现404错误以使用此方法

$app->get(
"/:table", function ($table) use($app){
    $db = new Db_handler;
    $result = $db->select_all($table);

    while($row = $result->fetch_assoc()){
        $dependency[] = $row ;
    }
    $struct = array("Dependencies"=>$dependency);

    $app->response->headers->set("Content-type","application/json");
    $app->response->status(200);
    $app->response->body(json_encode($struct));
}
);

0 个答案:

没有答案