Reputation: 47
I have a problem with laravel.
I have a connexion to a test database it's works but when I change the information for the production database it's not works.
Migration always migrate on the test database and not the production...
If you know if there is something else to change other than database.php in config directory, it will help me !
Thank's !
(Sorry for my english)
Upvotes: 0
Views: 683
Reputation: 6763
actually you should use .env file for that purpose.
here is a sample values set in .env for production
APP_ENV=production
APP_DEBUG=false
DB_CONNECTION=mysql
DB_HOST=localhost
DB_DATABASE=somedatabasename
DB_USERNAME=app_user
DB_PASSWORD=jdfnfjdfae126
How it works
lets say config/database.php has following value
'default' => env('DB_CONNECTION', 'mysql'),
this means check for the environment variable DB_CONNECTION
set in .env first, if its not set or null get 'mysql' from the config file, which is the mysql defined in config connections array in that file(database.php)
EDIT
as you have mentioned that you are using oracle driver. I think when you run
php artisan vendor:publish --tag=oracle
there will be a config file publish inside config folder. If config file is not publish, the package will automatically use what is declared on your .env file database configuration.
this file config/oracle.php
<?php
return [
'oracle' => [
'driver' => 'oracle',
'tns' => env('DB_TNS', ''),
'host' => env('DB_HOST', ''),
'port' => env('DB_PORT', '1521'),
'database' => env('DB_DATABASE', ''),
'username' => env('DB_USERNAME', ''),
'password' => env('DB_PASSWORD', ''),
'charset' => env('DB_CHARSET', 'AL32UTF8'),
'prefix' => env('DB_PREFIX', ''),
'prefix_schema' => env('DB_SCHEMA_PREFIX', ''),
],
];
similarly you can update the values here or mention it directly on .env file. Lets say your database name is mydatabase the value in
array would be
'database' => env('DB_DATABASE', 'mydatabase'),
if mentioned in .env file it would be
DB_DATABASE=mydatabase
Recommended way is to use .env file even though you publish the config file.so that you can ignore it in version control.
Upvotes: 2
Reputation: 1146
You have to edit .env file, this is the file that have the configuration to connect to database.
Hope it's usefull.
Upvotes: 0