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

LaraBABA's avatar

App name can only be changed in the .env

Hello,

I just started with Laravel and I am a bit lost with the initial setup.

I am trying to change the app name in the blade templates as:

{‌{ config('app.name', 'newname') }}

and also in the config/app.php file as:

'name' => env('APP_NAME', 'newname'),

I have also typed the commands

php artisan config:clear

php artisan cache:clear

But the name in the navbar still shows as "laravel".

But when I change the name in the .env APP_NAME= it works,

Any idea why please?

Also what is the piont of having this in blade 'name' => env('APP_NAME', 'newname'),

If the "newname" string cannot be taken.

Thanks in advance!

0 likes
4 replies
ModestasV's avatar

Well, for starters - if you have .env file with APP_NAME=Laravel - it will take that value and use it. If you were to change it there (actually you should change all possible values in .env file) - then it would change in your site.

As for the newname - this is a default value if .env file does not contain variable APP_NAME. If you would delete it from .env - it would take the second value.

Feel free to check: https://laravel.com/docs/5.5/helpers#method-env

1 like
neries's avatar

Try use

php artisan config:cache

command after change the app name in .env

1 like
Snapey's avatar
{‌{ config('app.name', 'newname') }}

says get the config value app.name but if it does not exist, use 'newname'

This

'name' => env('APP_NAME', 'newname'),

says set the config element 'name' to be whatever is in .env under APP_NAME but if it is not set, use 'newname'

so the root place to change is .env

after changing any config, run php artisan config:clear

Snapey's avatar

shit... old post which some idiot posted to and I did not notice

Please or to participate in this conversation.