• 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

Custom API and cunsuming in php?

Laravel Gates using model and returns "Using $this when not in object context" Line 28 of AzureUser model

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

CONCAT columns with Laravel 5 eloquent

Failing validation doesn't stop code execution in livewire component

Docker & Laravel : configure: error: Package requirements (oniguruma) were not met

How to break out of a foreach once a condition is met?

PHP's array_map including keys

How to send image,audio or video through the WhatsApp API - PHP

Return multiple values from a function using mysqli_fetch_assoc [closed]

Parameter is not sent to Laravel route in Ajax

Attempted to call an undefined method named "get" of class "MailController"

CodeIgniter extend CI_URI undefined method

Check for PDO Results, If None Display Message, If Yes then Loop Through

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

About Contact Privacy policy Terms and conditions