0
私は可能な方法を試してみたのですが、いつも同じエラーがあります。いくつかアドバイスをくれますか? pdt。私はエラー500スリムにデータを取得POST
おかげ
<?php
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;
$app = new \Slim\App;
$app->get('/api/products', function(Request $req, Response $res){
$query = 'SELECT * FROM products';
try{
$db = new database();
$db = $db->connection();
$stmt = $db->query($query);
$products = $stmt->fetch_object();
echo json_encode($products);
}catch(Exception $e){
echo $e;
}
});
$app->post('/api/add',function()use($app){
$request = Slim::getInstance()->request();
$name = json_decode($request->getBody());
//$content = file_get_contents($req);
//$json = json_decode($content, true);
//$post = $id->post;
echo $name;
});
POSTリクエストで[500内部サーバーエラー - スリムフレームワーク]の可能な複製(https://stackoverflow.com/questions/37189603/500-internal-server-error-with-post-request-slim-framework) – Nipun