2017-05-17 3 views
0

작동하지 내가 slimphp 라우터에 약간의 문제가 있습니다Slimphp 3 중첩 된 그룹

$app->group('/api', function() use ($app) { 

    // Library group 
    $this->group('/library', function() use ($app) { 

     // Get book with ID 
     $this->get('/books/:id', function ($req, $res) { 
      echo "books"; 
     }); 

     // Update book with ID 
     $this->put('/books/:id', function ($req, $res) { 

     }); 

     // Delete book with ID 
     $this->delete('/books/:id', function ($req, $res) { 

     }); 

    }); 

}); 

보내기를 GET에/API/도서관/책/1 나에게 문제가있는 Page not found 오류를 제공합니다.

EDIT :

의 .htaccess

RewriteEngine On 

# Some hosts may require you to use the `RewriteBase` directive. 
# If you need to use the `RewriteBase` directive, it should be the 
# absolute physical path to the directory that contains this htaccess file. 
# 
# RewriteBase/

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

PS : 간단한 app->get

+0

Slim 3 Documentation for Route Placeholders에서 발견 따라서 코드가 될 것이다 당신은 슬림 2 슬림 3를 사용하고 있습니까? 각 코드를 혼합하는 것 같습니다. – meun5

+0

슬림형 3을 사용하고 있습니다. – karim

+0

웹 서버 구성 (예 : .htaccess)을 추가 할 수 있습니까? – meun5

답변

0

그것은 슬림형으로하지 :id, 자리로 {id} 슬림형으로 3 개 용도가 발견되지 않고, 문제없이 작동 2 명이 그랬다.

$this->get('/books/{id}', function ($request, $response, $args) { 
    ... 
});