Fix last commit
dyb-tech.com/LaLiga-BackEnd/pipeline/head This commit looks good
Details
dyb-tech.com/LaLiga-BackEnd/pipeline/head This commit looks good
Details
This commit is contained in:
parent
b057ed2d1a
commit
85e8efbed9
|
|
@ -21,7 +21,8 @@
|
||||||
"symfony/runtime": "6.3.*",
|
"symfony/runtime": "6.3.*",
|
||||||
"symfony/twig-bundle": "6.3.*",
|
"symfony/twig-bundle": "6.3.*",
|
||||||
"symfony/validator": "6.3.*",
|
"symfony/validator": "6.3.*",
|
||||||
"symfony/yaml": "6.3.*"
|
"symfony/yaml": "6.3.*",
|
||||||
|
"ext-pdo": "*"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"allow-plugins": {
|
"allow-plugins": {
|
||||||
|
|
|
||||||
|
|
@ -2,17 +2,30 @@
|
||||||
|
|
||||||
namespace DMD\LaLigaApi\Controller;
|
namespace DMD\LaLigaApi\Controller;
|
||||||
|
|
||||||
|
use PDO;
|
||||||
|
use PDOException;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
|
||||||
class AdminController extends AbstractController
|
class AdminController extends AbstractController
|
||||||
{
|
{
|
||||||
#[Route('/admin', name: 'app_admin')]
|
#[Route('/admin/db-check', name: 'app_check_db', methods: ['GET'])]
|
||||||
public function index(): Response
|
public function index(): Response
|
||||||
{
|
{
|
||||||
return $this->render('admin/index.html.twig', [
|
$host = 'db.dyb-tech.com';
|
||||||
'controller_name' => 'AdminController',
|
$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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue