Php 更新/放置路由-不允许使用方法
我正在使用postman来测试我的API,但现在我对put路由有一个问题。 这是我写的一条put路线:Php 更新/放置路由-不允许使用方法,php,slim,Php,Slim,我正在使用postman来测试我的API,但现在我对put路由有一个问题。 这是我写的一条put路线: $app->put('/setting/{id}/settingvalue', function (ServerRequestInterface $request, Response Interface $response, $args) { try { $user = new \Riecken\PBS\controller\SettingsValueCont
$app->put('/setting/{id}/settingvalue', function (ServerRequestInterface $request, Response
Interface $response, $args) {
try {
$user = new \Riecken\PBS\controller\SettingsValueController();
$result = $user->updateOneSettingsValueinDetail( $args['id'], $request->getParsedBody());
$response = $response->withJson($result);
$response = $response->withStatus(200);
return $response;
}catch(Exception $e) {
$response->getBody()->write($e->getMessage());
return $response->withStatus($e->getCode());
}
});
这就是您在上面看到的函数(updateOneSettingsValueIndeail):
问题是Postman告诉我不允许使用该方法,只允许使用POST和GET:
有人知道这是什么类型的问题,解决方案是什么吗?这个回答来自Slim的NotAllowedHandler。而且它不仅仅是POST和GET默认设置。此响应与上述代码无关 您确定不自定义“NotAllowedHandler”并且不作为中间件绑定到应用程序吗 我写了这段代码,其中包含会产生相同情况的内容:
如果使用apache:apache错误日志中有错误消息吗?
public function updateOneSettingsValueinDetail ($settingsvalueIdToUpdate, $body) {
try {
return $this->SettingsValueDao->update($settingsvalueIdToUpdate, $body);
}catch(DAOException $e) {
throw new \Exception($e->returnErrorMessage(), $e->returnHttpCode());
}catch(\Exception $e) {
throw new \Exception("System Error", 500);
}
}