user3038607
user3038607

Reputation: 411

Laravel 5 - Why second parameter of env()

Almost every php files inside config folder has this function here -> env(). This function take 2 parameters like so :

'driver' => env('MAIL_DRIVER', 'smtp')

I know that the first parameter is to get the right line, but what's the meaning of the second parameter : smtp? I already provided the mail driver inside my .env file but I can't get it why is there 'smtp' inside env()

I looked around and nothing is talking about this. Thanks!

Upvotes: 2

Views: 1344

Answers (3)

Joel Hinz
Joel Hinz

Reputation: 25404

The second value is the default used if Laravel can't find an environment variable with the given key. So if you do have a MAIL_DRIVER environment variable set, that one will be used. If you don't, Laravel will use 'smtp' instead.

The same system is used for several other things Laravel does as well, for instance trans() and Config::get().

Upvotes: 9

enkodr
enkodr

Reputation: 11

It's the default parameter assumed by the framework if the value is not provided on the .env file.

Upvotes: 1

sergiodebcn
sergiodebcn

Reputation: 310

Is the default parameter if not custom parameter is defined in the .env file

Upvotes: 1

Related Questions