Laravel dotenv Kernel multile
Http/Kernel.php
.env .env-local.env .env-staging.env .env-production.env
class Kernel extends HttpKernel
{
public function __construct(Application $app, Router $router)
{
parent::__construct($app, $router);
$environmentPath = __DIR__.'/../../';
$dotenv = Dotenv::createUnsafeImmutable($environmentPath, '.env'); // getenv not thread safe
$dotenv->safeLoad(); //this is important
$dotenv = Dotenv::createUnsafeImmutable($environmentPath, '.env.'.getenv('APP_ENV').'.env'); // getenv not thread safe
$dotenv->safeLoad(); //this is important
}
.env```
APP_ENV=local
LOG_CHANNEL=stack
BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
.env.local.env```
APP_NAME=OOXX_Local
APP_KEY=base64:NDvP.........g=
APP_DEBUG=true
APP_URL=http://localhost
QUERY_DETECTOR_ENABLED=true
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_NOTIFY=true
MAIL_MAILER=smtp
MAIL_HOST=smtp.ooxx.org
MAIL_PORT=587
MAIL_USERNAME=ooxx@ooxx.com
MAIL_PASSWORD=
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=ooxx01@ooxx.com
MAIL_FROM_NAME="${APP_NAME}"
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=
AWS_BUCKET=
AWS_BUCKETTEST=
.env.local.env```
APP_NAME=OOXX_Local
APP_KEY=base64:NDvP………g=
APP_DEBUG=false
APP_URL=http://staging.ooxx.com
QUERY_DETECTOR_ENABLED=false
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_NOTIFY=true
MAIL_MAILER=smtp
MAIL_HOST=smtp.ooxx.org
MAIL_PORT=587
MAIL_USERNAME=ooxx@ooxx.com
MAIL_PASSWORD=
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=ooxx01@ooxx.com
MAIL_FROM_NAME="${APP_NAME}"
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=
AWS_BUCKET=
AWS_BUCKETTEST=