I made this class to create a JSON to return in my Web Service , but not working, would anyone know why?
Class Useful
<?php
class Uteis {
public static function criarjson($mensagem,$value){
$json_str = '{"autenticado":$value, "mensagem":$mensagem}';
$json = json_decode($json_str);
return json_encode($json);
}
}
?>
Index.php
$app->post('/login',function(Request $request,Response $response){
$allquery = $request->getQueryParams();
$user = new Usuario();
$sql = new Sql();
$autenticado = $user->login($allquery['login'],$allquery['senha']);
if ($autenticado) {
$response = Uteis::criarjson("AA",true);
}else{
$response = Uteis::criarjson("Erro ao autenticar",false);
}
return $response;
});
$app->run();