Symfony-check

Check if your symfony application is ready for deployment

Symfony Check
Remove "/backend.php/" from your uri
  • design

In the apps/frontend/config/settings.yml file, you can delete the application name from your uri by activing the no_script_name option.

This option is enabled for the first generated application (most often, the frontend), but not for the others.

Why ?

Because without the application name, symfony wouldn't know which one to use when the applications share the same domain.

We have to find an other way to let symfony know which application to use.

A solution can be to use several domains :

  • http://my-app.com for the frontend
  • http://my-app-backend.com for the backend

Personnally, I prefer use some sub domains for each application :

  • http://my-app.com for the frontend
  • http://admin.my-app.com for the backend

If your project is hosted on a dedicated server

You juste have to add a new virtual host in httpd.conf :

<VirtualHost *:80>
  ServerName admin.my-app.com
  DirectoryIndex backend.php
  DocumentRoot "/path/to/the/web/directory"
  <Directory "/path/to/the/web/directory">
    AllowOverride All
    Allow from All
  </Directory>
  Alias /sf /path/to/the/symfony/data/web/sf
  <Directory "/path/to/the/symfony/data/web/sf">
    AllowOverride All
    Allow from All
  </Directory>
</VirtualHost>

If your project is hosted on a shared hosting environment

In that case, you probably can't access to the httpd.conf.
So let's play with the /web/.htaccess. Just after :

<IfModule mod_rewrite.c>
  RewriteEngine On

Add the following lines:

# The admin subdomain returns to the backend
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} ^admin\.my-app\..*
RewriteRule ^(.*)$ backend.php [QSA,L]

Now, you can modify settings.yml

prod:
  .settings:
    no_script_name:  true

Don't forget to clear the cache.

php symfony cc