• 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

Can't exclude directories from .htaccess mobile redirect?

Sum array values

Remove categories with all childs derived from parent category

Fatal error: Uncaught TypeError: count(): Argument #1 ($var) must be of type Countable|array, null given in

How can I get user id from session in javascript?

api response laravel doesn't show

Can I write PHP code across multiple lines per statement?

Reorder attribute dropdown terms in Woocommerce single variable products

Laravel insert dynamic input values with radio button

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

Laravel unique validation on multiple columns

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

Getting values for an enum?

Why rand() every time I refresh the page?

Elastic Beanstalk with Laravel Envoy

About Contact Privacy policy Terms and conditions