File tree Expand file tree Collapse file tree 1 file changed +7
-10
lines changed Expand file tree Collapse file tree 1 file changed +7
-10
lines changed Original file line number Diff line number Diff line change 7
7
use Codefy \Framework \Support \CodefyServiceProvider ;
8
8
use PDO ;
9
9
10
- use function Codefy \Framework \Helpers \env ;
10
+ use function Codefy \Framework \Helpers \config ;
11
11
use function sprintf ;
12
12
13
13
final class PdoServiceProvider extends CodefyServiceProvider
14
14
{
15
15
public function register (): void
16
16
{
17
- if ($ this ->codefy ->isRunningInConsole ()) {
18
- return ;
19
- }
20
-
17
+ $ default = config (key: 'database.default ' );
21
18
$ dsn = sprintf (
22
19
'%s:dbname=%s;host=%s ' ,
23
- env (key: ' DB_DRIVER ' ),
24
- env (key: ' DB_NAME ' ),
25
- env (key:' DB_HOST ' )
20
+ config (key: " database.connections. { $ default } .driver " ),
21
+ config (key: " database.connections. { $ default } .dbname " ),
22
+ config (key: " database.connections. { $ default } .host " )
26
23
);
27
24
28
25
$ this ->codefy ->define (name: PDO ::class, args: [
29
26
':dsn ' => $ dsn ,
30
- ':username ' => env (key: ' DB_USER ' ),
31
- ':passwd ' => env (key: ' DB_PASSWORD ' ),
27
+ ':username ' => config (key: " database.connections. { $ default } .username " ),
28
+ ':passwd ' => config (key: " database.connections. { $ default } .password " ),
32
29
]);
33
30
34
31
$ this ->codefy ->share (nameOrInstance: PDO ::class);
You can’t perform that action at this time.
0 commit comments