• 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

Laravel multi auth - Authentication user provider [] is not defined

Elastic Beanstalk with Laravel Envoy

Show date difference as "20" instead of "20 years ago"

Magento 2 - Controller returning blank page

Yii2: How to download backup files using spanjeta/yii2-backup?

Override default Auth routes in Laravel 7

How to implement placeholder in a php file for moodle plugin?

Could not decode a text frame as UTF-8.

how to use extended ASCII instead of unicode in PHP

protect my blog content

image source not readable

HTML and PHP in one file

Uploading video to Youtube using Youtube Data API V3 and Google API Client PHP -- getting 401 (unauthorized) message

PHP cURL (SSL certificate problem: self signed certificate in certificate chain)

How to make dot match newline characters using regular expressions

About Contact Privacy policy Terms and conditions