M Markero
M Markero

Reputation: 199

Symfony 2 - Project configuration on production

I finished my website based on Symfony2 and It's running on app_dev.php. I want to get it visible for users through app.php.

1) How can I configure my project so that users can access it through app.php?

2) How can I remove app.php from the url domain.com/app.php/{slug}?

What else do I need to do when finishing developing my website?

Thanks!

Upvotes: 0

Views: 95

Answers (2)

lvarayut
lvarayut

Reputation: 15349

1) How can I configure my project so that users can access it through app.php?

The app_dev.php is used when you are developing your website - Dev environment. So, you can see the developer toolbar. If you finished developing your website, you will need to change to prod environment by using the following command:

php app/console cache:clear --env=prod --no-debug
php app/console assets:install web_directory
php app/console assetic:dump web_directory

2) How can I remove app.php from the url domain.com/app.php/{slug}?

To remove the app.php from your url, you can set the web root of your project to the web folder. It's best to do this with apache using virtual hosts, but there are ways to do it with the htaccess.

Here is the example of my Virtual Hosts

<VirtualHost *:80>
    DocumentRoot "path_to_symfonyTest/web"  
    ServerName "symfonyTest"  
    <Directory "path_to_symfonyTest/web">
        DirectoryIndex app_dev.php
        AllowOverride All
        Order allow,deny
        Allow from all
        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^(.*)$ app_dev.php [QSA,L]
        RedirectMatch permanent ^/app_dev\.php/(.*) /$1
    </Directory>
</VirtualHost>

Or If you need to achieve this by using htaccess, see this site

You can see more information How to deploy a Symfony2

Upvotes: 1

Udan
Udan

Reputation: 5609

You can change your vhost definition, provided you use apache:

DirectoryIndex app.php

EDIT: based on comment

then you can set it this way :

server {
    index app.php;
}

Check this resource too: http://wiki.nginx.org/Symfony

Upvotes: 0

Related Questions