• 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

How to add automatically collapse/expand in content wordpress (single.php)?

PHP7 CLI attempts to load xdebug twice - "Cannot load Xdebug - it was already loaded"

How do I call Validator from a namespace with an already existing Validator class

How to average columns of data from multiple, flat arrays?

Why isn't my PHP exception working?

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given [duplicate]

How to Install Composer Require doctrine/dbal

ldap is missing from system when installing adldap2 in laravel

merging two arrays with specified index

Dynamic dropdown Ajax PHP request

Can I write PHP code across multiple lines per statement?

Problem with fetching data from database in Laravel

PHPExcel How to set conditional formatting to change cell background color based on cells values

generate an Excel file using PHP

Popup Window and PHP form

About Contact Privacy policy Terms and conditions