i download from https://github.com/luciddreamz/laravel laravel for openshift
then upload over my repository over github . this code for connect to database not work.
the problem is that load variable from .env
file that locate in root of project
for solve this problem change.env
# local environment only
# for production, see .openshift/.env
APP_ENV=APPLICATION_ENV
APP_DEBUG=true
APP_URL=OPENSHIFT_APP_DNS
APP_KEY=OPENSHIFT_SECRET_TOKEN
DB_DRIVER=mysql
DB_HOST=OPENSHIFT_MYSQL_DB_HOST
DB_PORT=OPENSHIFT_MYSQL_DB_PORT
DB_DATABASE=OPENSHIFT_APP_NAME
DB_USERNAME=OPENSHIFT_MYSQL_DB_USERNAME
DB_PASSWORD=OPENSHIFT_MYSQL_DB_PASSWORD
CACHE_DRIVER=apc
SESSION_DRIVER=file
my error :SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known
createConnection('mysql:host=OPENSHIFT_MYSQL_DB_HOST;port=OPENSHIFT_MYSQL_DB_PORT;dbname=OPENSHIFT_APP_NAME',
array('driver' => 'mysql',
'host' => 'OPENSHIFT_MYSQL_DB_HOST',
'port' => 'OPENSHIFT_MYSQL_DB_PORT',
'database' => 'OPENSHIFT_APP_NAME',
'username' => 'OPENSHIFT_MYSQL_DB_USERNAME',
'password' => 'OPENSHIFT_MYSQL_DB_PASSWORD',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
'name' => 'mysql'),
array('0', '2', '0', false, '0')) in MySqlConnector.php line 20
We're using symfony with doctrine and we are in the process of automating deployment. I got this error when I simply hadn't provided the correct db creds in parameters.yml (I was running doctrine:migrations:migrate)
This thread has sent me on a bit of a wild goose chase, so I'm leaving this here so others might not have to.
I'm using Laravel with Docker. I solved this problem by changing the value of
DB_HOST
fromlocalhost
tomysql
.