S
S
Stanislav2022-02-08 00:59:45
PHPUnit
Stanislav, 2022-02-08 00:59:45

Why doesn't DB_CONNECTION work in Laravel 5.3?

Introductory: judging by the documentation and publications on the Internet , this variable in Laravel must somehow replace the name of the default settings in config.database.default. However, this doesn't work, and we couldn't find such logic in the Laravel code either.

Question: How can I set the default database settings name value for PhpUnit tests? The variable mentioned above is set via <env name="DB_CONNECTION" value="testing"/>, everything is great, but it does not affect anything.

Clarification: the connection settings themselves with the name (key in the config) testing, of course, are available. Also, it was not possible to find a mention of the DB_CONNECTION environment variable in the framework code.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey delphinpro, 2022-02-08
@lamo4ok

This is not a database name.
This is the name of the key in the config (array /config/database.php/connections) with the connection parameters that will be used.
Create an appropriate section and use

Also, it was not possible to find a mention of the DB_CONNECTION environment variable in the framework code.

In configs and used. Environment variables are generally only in configs and can be used.
6202225995b5b645456581.png

I
inFureal, 2022-02-08
@inFureal

Add to config/databade.php in the connections key called testing. And by analogy with others, fill

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question