Fix last commit
dyb-tech.com/LaLiga-BackEnd/pipeline/head This commit looks good Details

This commit is contained in:
Daniel Guzman 2024-08-11 01:39:34 +02:00
parent b057ed2d1a
commit 85e8efbed9
2 changed files with 19 additions and 5 deletions

View File

@ -21,7 +21,8 @@
"symfony/runtime": "6.3.*",
"symfony/twig-bundle": "6.3.*",
"symfony/validator": "6.3.*",
"symfony/yaml": "6.3.*"
"symfony/yaml": "6.3.*",
"ext-pdo": "*"
},
"config": {
"allow-plugins": {

View File

@ -2,17 +2,30 @@
namespace DMD\LaLigaApi\Controller;
use PDO;
use PDOException;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class AdminController extends AbstractController
{
#[Route('/admin', name: 'app_admin')]
#[Route('/admin/db-check', name: 'app_check_db', methods: ['GET'])]
public function index(): Response
{
return $this->render('admin/index.html.twig', [
'controller_name' => 'AdminController',
]);
$host = 'db.dyb-tech.com';
$dbname = 'laliga';
$username = 'mamb';
$password = 'lakers06';
try {
$dbConnection = new PDO("mysql:host=$host;dbname=$dbname", $username, $password);
$dbConnection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
return new JsonResponse("Connected successfully");
}
catch(PDOException $e)
{
return new JsonResponse("Connection failed: " . $e->getMessage());
}
}
}