• 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

Getting values for an enum?

Natural ORDER in Laravel Eloquent ORM

How to show selected value using javascript in laravel

Require a class from another class - php

Nginx disallowing execution of PHP in uploads directory with Magento

Create a zip file and download it

How to pass data to all views in Laravel 5?

Symfony there are no commands defined in the "make" namespace

Creating a config file in PHP

Applying programmatically a coupon to an Order in WooCommerce3

Google API Heatmap Layer exception, why?

Laravel after login Two factor not working

Doctrine ORM: Excluding Records Based on Values of Nested Relationships

Laravel Model save() & update() Not Saving

Natural ORDER in Laravel Eloquent ORM

About Contact Privacy policy Terms and conditions