• 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/docker-compose/redis - Class 'Redis' not found

SendGrid: Sending an email to multiple recipients without other emails being shown on the "to" field

Convert every two values of an associative array into key-value pairs

Laravel insert dynamic input values with radio button

Unable to create lockable file - Laravel 8 & PHP 8

PHP block shortcut in Visual Studio Code

How can I pass the list to the component variable in Laravel?

How to get Laravel's CSRF Token from Another Website?

If you intend you use SMTP, add your SMTP Code after this Line

How to make dot match newline characters using regular expressions

500 Internal Server Error on Ajax request. Not sure the origin of the problem

(Laravel) How to delete multiple models including optional relationships?

Facebook PHP SDK - will not logout properly

laravel sanctum Route [login] not defined

MySQL/PHP - Web Based Game -User specific inventory table or 1 giant table? Another option?

About Contact Privacy policy Terms and conditions