Laravel 5 configuration arrays?

In Laravel 4, you can customize your environment’s configuration folder structure:

/config/app.php
/config/dev/app.php
/config/staging/app.php
/config/testing/app.php

Can you do it with Laravel 5? I understand the concept .env, and I use this to determine which environment I enter. But I need to determine the configuration value, which is an array of arbitrary length, and you cannot do this with files .env.

An example of what I'm trying to achieve:

if (in_array($request->input('value'), config('app.valid_values')) {
  // do something
}

This valid_valuesis just an array of values. It is of arbitrary length, so you cannot just install them in your .envfile, for example:

VALID_VALUE1=...
VALID_VALUE2=...
etc.

And the array should be different for each environment.

This was easy to do in Laravel 4 with environment configuration folders. But how do you do it with Laravel 5?

+4
1

, , ,

MY_ARRAY_VALUE=1,2,house,cat,34234

$myArrayValue  = explode(',', env('MY_ARRAY_VALUE'));

JSON json_decode()

$myArrayValue  = json_decode(env('MY_ARRAY_VALUE'), true);

:

Laravel 5 .env.

.env .

, APP_ENV .env

APP_ENV=local

https://laravel.com/docs/5.2/configuration#environment-configuration

Laravel 5.0 https://laravel.com/docs/5.2/releases#laravel-5.0

Laravel 5 DotEnv Vance Lucas. Laravel 5 . .

.env : https://github.com/laravel/laravel/blob/master/.env.example

, . , , . , .

cinch, Laravel DotEnv PHP Vance Lucas. Laravel .env.example. Laravel Composer, .env. .

+4

All Articles