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

yijani's avatar

Laravel config application name

I have a question that might be kinda newbie but I don't know then I have to ask.

I'm using config('app.name') on my html to set the title of my website based on what is set to that config variable, but I was wondering... Is it allowed to have spaces? And also, can I set the entire subtitle such as: My Website - The best website you'll ever find? Or it's going to be a problem later cause this variable is used somewhere down the code that won't support that?

0 likes
11 replies
tomasz.r's avatar

I believe app name is only used in presentation. Also, it's a string, so it shouldn't be a problem to set it to anything you like.

1 like
J_shelfwood's avatar

You should be fine with changing it to whatever you want, it is as far as I know only used in view's or mail templates. If you'd want to change your app namespace for your code so YourCompany\Http\Controllers instead of App\Http\Controllers you'd use php artisan app:name {name}.

@yijani To give another example of how your app.name would be used is in the title of your pages.

1 like
martinbean's avatar

@yijani Yes, you can include spaces in the app.name configuration value. I wouldn’t include a sub-title in there though; literally use the app name only.

1 like
tomasz.r's avatar

@yijani by presentation I mean things like titles, mail headings, etc.

1 like
yijani's avatar

@martinbean then how would I set the sub-title? It would be interesting the index page to have the sub-title as I mentioned like The best website on the internet and on other pages have a different subtitle, how to set that Interactively?

1 like
martinbean's avatar
Level 80

@yijani Set it in the same file:

<!-- config/app.php -->
<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Application Name
    |--------------------------------------------------------------------------
    |
    | This value is the name of your application. This value is used when the
    | framework needs to place the application's name in a notification or
    | any other location as required by the application or its packages.
    */

    'name' => 'Your App Name',

    'subtitle' => 'Your app’s subtitle',

    // Other configuration settings...

];

And then use them in your Blade views:

<title>{{ config('app.name') }} - {{ config('app.subtitle') }}</title>

As soon as you include the subtitle in the app.name configuration value, you’re going to find an instance where you’re go, “Damn, I wish I could get just the app’s name, not the app’s name and subtitle.”

One scenario I can think of is copyright notices:

<p>&copy; {{ date('Y') }} {{ config('app.name') }}. All rights reserved.</p> 

You don’t want your site’s subtitle printed there; just the app name.

5 likes
antiomic's avatar

What of doing this on the html to set the title?

 config('app.name', 'Laravel') 

I tried it though but it didn't work. Can somebody tell why?

kevin73911's avatar

You just need to change the .env file's APP_NAME and everything will be fine. :)

1 like
SS54's avatar

could you kindly explain where does config(spp.name)come from. I know it is used to to set the title of the web page and based on the .env file. I do not understan how a video tut suddendly used the the config method. I should so grateful if anyone explain it.

Please or to participate in this conversation.