Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

catto's avatar
Level 1

Cannot get value from config in Lumen

I want to change the timezone in lumen, but I cannot get the value from config, it always give the default value UTC.

I've tried everything I know, to the point changing the default value to what I wanted. But still the timezone wont change

AppServiceProvider

public function register()
    {
        //set local timezone
		date_default_timezone_set(config('app.timezone'));
		//set local date name
		setLocale(LC_TIME, $this->app->getLocale());
        
		URL::forceRootUrl(Config::get('app.url'));
    }

Bootstrap.app

(new Laravel\Lumen\Bootstrap\LoadEnvironmentVariables(
    dirname(__DIR__)
))->bootstrap();

date_default_timezone_set(env('APP_TIMEZONE', 'Asia/Jakarta'));

$app->configure('app');

Config.app

'timezone' => env("APP_TIMEZONE", "Asia/Jakarta"),

.env

APP_TIMEZONE="Asia/Jakarta"
APP_LOCALE="id"

Also if I make a variable inside config.app such as:

'tes_var' => 'Test'

And using it like this:

\Log::info(config('app.tes_var'));

The result in Log is null, I can't get the value from tes_var.

I don't have any idea what's wrong here, if it's in Laravel maybe this is happened because cached config, but there's no cached config in Lumen. Maybe I miss some configuration here?

Thanks

0 likes
3 replies
catto's avatar
Level 1

@Sinnbeck My server doesn't support php 8, so I choose Lumen because it is more faster for php 7. I can't use anything like octane, and I can't update the php version on my server

Please or to participate in this conversation.