So I am starting a docker symfony 4 project and i am trying to use a controller. I already created the database that i need by running doctrine:database:create
and it work and created my database so the connection is good. however, when i run this code below. I get that error. I a little confuse on why mysql doesnt connect. anyone know?
Ive tried change mysql versions, composing it down and updating different mysql root and password and is not connecting.
class HospitalAdminController extends AbstractController
{
/**
* @Route("/admin/hospital/new")
*/
public function new(EntityManagerInterface $em)
{
$hospital = new Hospital();
$hospital->setName('Example Hospital')
->setPhone(8175831483)
->setAddress('123 Avenue');
$em->persist($hospital);
$em->flush();
return new Response(sprintf(
'Hiya! New Hospital id: #%d phone:%s address%s',
$hospital->getId(),
$hospital->getPhone(),
$hospital->getAddress()
));
}
}
just trying to run my controller and do a proof of concept.