Can anyone explicitly tell me how to connect a my symfony2 App to ClearDB on heroku?
I got the connection string on heroku by typing
$ heroku config
but when i put the results on my parameters.yml i get a SQLSTATE[HY000] [2002] Connection refused error.
Thanks in advance
This will help anyone else stuck like I was:
Put your connection parameters in parameters.php
instead of parameters.yml
as below
<?php
// Using ClearDB for mysql database
$db = parse_url($_ENV['CLEARDB_DATABASE_URL']);
$container->setParameter('database_driver', 'pdo_mysql');
$container->setParameter('database_host', $db['host']);
$container->setParameter('database_port', '~');
$container->setParameter('database_name', trim($db['path'], '/'));
$container->setParameter('database_user', $db['user']);
$container->setParameter('database_password', $db['pass']);
// Using Mandrill to send email
$container->setParameter('mailer_transport', 'smtp');
$container->setParameter('mailer_host', 'smtp.mandrillapp.com');
$container->setParameter('mailer_user', $_ENV['MANDRILL_USERNAME']);
$container->setParameter('mailer_password', $_ENV['MANDRILL_APIKEY']);
// Other settings
$container->setParameter('locale', 'en');
$container->setParameter('secret', 'your_secret');
?>
Include parameters.php
in your config file:
imports: - { resource: parameters.php}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With