0
votes

I am running Apache 2.4 on my development machine so I can test code locally. How do I tell Symfony 3.4 to use the 'dev' environment instead of the 'prod' environment?

I've tried browsing to http://localhost/app_dev.php but that just redirects to http://localhost/. It looks like the front controller is set in .htaccess but if I modify that file, then my production server will be using the wrong front controller.

I've read the docs on the following pages and it talks about how to create new environments but not how to set the default environment.

https://symfony.com/doc/3.4/configuration/environments.html

https://symfony.com/doc/3.4/setup/web_server_configuration.html

I'm running Apache 2.4 on Windows 10 and here is my vhost configuration

<VirtualHost *:80>
    ServerName example.local
    DocumentRoot "C:\Users\kento\PhpstormProjects\example\web"
        <Directory "C:\Users\kento\PhpstormProjects\example\web">
                Options Indexes FollowSymLinks
                AllowOverride All
                Require all granted
                DirectoryIndex app_dev.php
        </Directory>
    ErrorLog "logs/example-error.log"
    CustomLog "logs/example-access.log" common
</VirtualHost>

example.local points to 127.0.0.1 in my hosts file. I set DirectoryIndex to app_dev.php but that seems to be overridden by the .htaccess file.

1
How did you configure your Apache? What is your vhost configuration? are you setting up on Linux?Aakash Tushar

1 Answers

1
votes

You've already set the vhost to use app_dev.php, but then you allow a .htaccess to override with the AllowOverride All. Change that to AllowOverride None and the .htaccess will be ignored.

There may be some config from there you would be able to merge into the vhost.

I tend to prefer all the configuration in the virtual host, and not have any use of a .htaccess file, for a small speed boost - especially in production.