• 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

Unable to uninstall brew php from homebrew

WooCommerce - unset "<product> removed notice…" on cart page

Assign output of PHP function to a variable

Target class controller does not exist - Laravel 8

Artisan, creating tables in database

Laravel SQL query midnight time not showing

WordPress - Dynamically add user ID to the end of a URL

Explode not working properly with dash

How to solve cURL error 60: SSL certificate in Laravel 5 while Facebook authentication

PHP error: "The zip extension and unzip command are both missing, skipping."

WordPress + Nginx on non-standard port behind AWS ELB results in broken links

Maatwebsite Excel 3.1 : how do I skip duplicate data when imported?

How to map the two arrays with a duplicate value?

PHP returning an error message and false

How can I format this number correctly using PHP?

About Contact Privacy policy Terms and conditions