peace_love
peace_love

Reputation: 6461

How can I run Symfony 4 in production mode?

I am using the Symfony profiler. But I actually only want to make it visible in the Dev mode. But when I push the data via git on my server and open the website, I see the profiler. That does not make sense of cause, but I do not know how to remove it.

I was looking for the file called config/config_dev.yml and config/config.yml because I would think that in config/config.yml I should just set to:

web_profiler:
    toolbar: false
    intercept_redirects: false

But I do not have any config.yml files. Do I have to create them?

Upvotes: 0

Views: 4176

Answers (1)

Aurelien
Aurelien

Reputation: 1507

On your server, copy your .env.dist (if you have one) to .env, and set APP_ENV=prod

If you don't yet have a .env file, create one at the root of you project, and put APP_ENV=prod in it.

That being said, note that best practice is to use server level configuration in production env. Reference link : https://symfony.com/doc/current/configuration/external_parameters.html#configuring-environment-variables-in-production

EDIT (based on the comments) for your information :

.env is a file where you will mainly put your global configuration. The .dist variant is meant to be added to git, it won't be used by symfony but is useful for the developpers (including you) to have a default config file to rely on.

Basically, when they'll pull the project for the first time, they'll copy this file to .env then adjust the lines/config to their liking. The .env must not be added to git for it will be the file that will be used by symfony. If you add it to git, each time you will push your local work then pull from your server, it will replace your server configuration with your local one.

Upvotes: 5

Related Questions