2

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!

user3038607
  • 411
  • 3
  • 7
  • 18
  • I imagine that this is a function in laravel that simply wraps http://php.net/manual/en/function.putenv.php or something similar. The second parameter is the value for the environmental variable itself. So in your case you're setting the `MAIL_DRIVER` environmental variable to be `smtp` – EdgeCaseBerg May 20 '15 at 16:44
  • the documentation for the `env` function can be found here: http://laravel.com/docs/5.0/helpers – EdgeCaseBerg May 20 '15 at 16:46

3 Answers3

8

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().

Joel Hinz
  • 24,719
  • 6
  • 62
  • 75
1

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

sergiodebcn
  • 310
  • 1
  • 12
1

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

enkodr
  • 11
  • 1