Laravel 9 access .env variable in blade
In Laravel 9, you can access the variables defined in the .env
file in your blade views using the env
function.
Here's an example of how to use the env
function in a blade view:
bash<title>{{ env('APP_NAME') }}</title>
In this example, we're using the env
function to retrieve the value of the APP_NAME
variable from the .env
file and use it as the title of the page.
You can also provide a default value to the env
function in case the variable is not defined in the .env
file:
bash<title>{{ env('APP_NAME', 'My Laravel App') }}</title>
In this example, if the APP_NAME
variable is not defined in the .env
file, the title of the page will be set to "My Laravel App".
Comments
Post a Comment