How you set the application_name attribute for PostgreSQL in Laravel?

1.2k Views Asked by At

How do I set the application_name as defined here http://www.postgresql.org/docs/9.1/static/libpq-connect.html, in Laravel? I see that you can do "SET application_name = 'application'" but this does not work for me. I also tried setting it in the app/config/database.php file in the 'connections' array. What am I doing wrong?

2

There are 2 best solutions below

1
On

You have to put in the env file (/.env) the variable regarding the application name named DB_APPLICATION_NAME = ;

And you have to specify the following: Form Laravel version 5.5 you can add this row to the file /config/database.php at the bottom of the postgresql connection. 'application_name' => env('DB_APPLICATION_NAME', 'Laravel')

If you don't specify the app name in the .env file the application name will be taken from /config/database.php file.

0
On
# database.php
'application_name' => env('DB_APPLICATION_NAME', 'Laravel')