I'm having problems with the slim DELETE, it has a 404 error, follow the code:
<?php
require '../Slim/Slim.php';
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
$app->response()->header('Content-Type', 'application/json;charset=utf-8');
$app->get('/', function () {
echo "SlimProdutos Welcome";
});
$app->delete('/produtos2/:id','deleteProduto');
$app->run();
function getConn()
{
return new PDO('mysql:host=localhost;dbname=Slim',
'root',
'mxk8mxk9',
array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8")
);
}
function deleteProduto($id)
{
$sql = "DELETE FROM produtos WHERE id=:id";
$conn = getConn();
$stmt = $conn->prepare($sql);
$stmt->bindParam("id",$id);
$stmt->execute();
echo "{'message':'Produto apagado'}";
}
I only use http and I do not use any other page / form to call it
I'm opening it up like this link 111 is the id that I want to delete!
Another question is about the function of Slim, it basically serves to use POST, GET, PUT, DELETE, etc ... with routes and json, right? does it have other utilities?