• 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

Make survey at laravel 5.4 and MySQL

PHP password_verify

Unable to create lockable file - Laravel 8 & PHP 8

Update Order custom Field value with WooCommerce REST API

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

Using Associative arrays

What's the net::ERR_HTTP2_PROTOCOL_ERROR about?

mysql slow on updates for a well optimized query

Unable to create lockable file - Laravel 8 & PHP 8

Creating Combinations of Elements

Laravel whole batch is cancelled if one Job fails

sort() not affecting original array while inside foreach loop

Failing validation doesn't stop code execution in livewire component

Whats the point of running Laravel with the command 'php artisan serve'?

how to validate form data in codeigniter 4

About Contact Privacy policy Terms and conditions