• 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 Sanctum CSRF not authenticating

How do I upload a laravel project on cPanel shared hosting?

Get WooCommerce products from specific category

Laravel relationship belongsToMany with composite primary keys

woocommerce get_order_report_data to show order_item_id

PHPUnit 7: Failed asserting that exception of type InvalidArgumentException is thrown

Laravel display validation error

Why the name of trucks are same in 2nd and 3rd record of company data retrieval?

In PHP, which is faster: preg_split or explode?

Is it possible to re-use an array taken from PHP via JSON in a $.ajax function?

How in Laravel run JavaScript code stored in php variable?

Session timeout in Yii2

Confirm Leave on External Links in Wordpress

Handle error for duplicate entries - PHP/MySQL

Fetch files from next cloud storage and display in Laravel website

About Contact Privacy policy Terms and conditions