Wednesday 23 October 2019

Laravel database migration knowledge

Laravel reads the database connection parameters specified in :


config/database.php, but if DB parameters are specified in .env, these will parameters will override

because the lines specified in config/database.php always tries to read env file first by the function
env('env_paramter', 'value'); this function means it will read env_parameter first, if not specified, it will take 'value'


as you can see from the code


    'default' => env('DB_CONNECTION', 'sqlsrv'),


     'sqlsrv' => [
            'driver' => 'sqlsrv',
            'host' => env('DB_HOST', 'localhost'),
            'port' => env('DB_PORT', '1433'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'charset' => 'utf8',
            'prefix' => '',
            prefix_indexes' => true,

     ]

https://stackoverflow.com/questions/35075736/laravel-using-env-but-not-using-config-in-config-database-php

No comments:

Post a Comment