Dorokhov.codes

03. Configuration

All config files are located in the config folder.

We can pass parameters through the .env file. All the variables listed in the .env file will be loaded into the $_ENV PHP super-global when your application receives a request.

And then we can get these parameters:

$url = $_ENV['APP_URL'];

// Laravel specific:
$url = env('APP_URL');

// The second value passed to the env function is the "default value":
$url = env('APP_URL', 'http://localhost');

How to get parameters?

config('app.timezone');
config('database.connections.mysql.database');

The APP_KEY is mandatory parameter to start Laravel. So make sure configuration has this option (in config/app.php, .env).

If you are developing with a team, you may wish to continue including and updating the .env.example file with your application. By putting placeholder values in the example configuration file, other developers on your team can clearly see which environment variables are needed to run your application.

Any variable in your .env file can be overridden by external environment variables such as server-level or system-level environment variables.

Timezone

config/app.php:

'timezone' => 'Europe/Kiev',
'timezone' => 'UTC',

User-generated files

The storage/app/public directory may be used to store user-generated files, such as profile avatars, that should be publicly accessible. You should create a symbolic link at public/storage which points to this directory. You may create the link using the php artisan storage:link Artisan command.