• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

How to change the app environment at run time?

phplaravel


PHP Snippet 1:

dump(config('app.env')); // "testing"

config(['app.env' => 'production']);

dump(config('app.env')); // "production"

PHP Snippet 2:

dump(app()->environment()); // "testing"

app()['env'] = 'production';

dump(app()->environment()); // "production"

PHP Snippet 3:

$this->app['env'] = 'production';

Related Snippets

Convert string to lowercase AND then convert it to its original form in PHP, is it possible?

Laravel 5.1 Unknown database type enum requested

How to fix " Uncaught TypeError: Argument 1 passed to JpGraphException::defaultHandler() " problem in php 7.1.3 and jpgraph 4.2.6?

How to retrieve Active Directory group policy maximum password age using LDAP

Laravel: Create morphs() relationship nullable

Undefined variable in Laravel 8 project (php 7.4)

Getting values for an enum?

Laravel Blade checkbox not checked

How do I remove this delivery notification from here?

VichUploaderBundle error "Expected argument of type "File", "NULL" given" when submitting the form without selecting any file

Laravel Command Schedule Not Working Properly

Target class controller does not exist - Laravel 8

Laravel 8: Array to string conversion while calling route:list

How to change product Image when variables are selected in Shop and Archive Pages?

Laravel: HTML in notification

About Contact Privacy policy Terms and conditions