I
I
Ivan2014-08-14 17:33:04
symfony
Ivan, 2014-08-14 17:33:04

What is the best way to switch between environments in Symfony?

Good evening.
How to configure nginx to easily switch between app.php and app_dev.php?
I tried to do acme.com/... for production and acme.com/app_dev.php /... for development . requests go to acme.com/app_dev.php/foo.js You can do a rewrite in the location for statics, removing app_dev.php from the address, but it didn't work for me :) And I'm not sure if this is the best option. I can’t return statics through the controller in the dev environment because of the fonts that have to be copied manually to the web / fonts folder (using symfony, I understand there, they cannot be returned as other statics).

nginx config
root /home/ivan/sites/acme.com/web;

location / {
    try_files $uri /app.php$is_args$args;
}

location ~* \.(?:jp?g|gif|png|ico|svg|css|js|swf|zip|tar|tgz|gz|rar|bz2|doc|docx|xls|xlsx|ppt|pptx|exe|msi|txt|mp3|mp4|mkv|mpg|mov|fla|eot|otf|ttf|woff)$ {
    expires 360d;
    access_log off;
    log_not_found on;
    
    # пытался сделать тут костыль, но он не работает
    # if ($request_uri ~ ^/(app|app_dev).php) {
    #     rewrite ^/(app|app_dev).php/$ /$1 last; break;
    # }
    
    try_files $uri =404;
}

location ~ ^/(app|app_dev|config)\.php(/|$) {
    fastcgi_pass php-fpm-acme;
    fastcgi_split_path_info ^(.+\.php)(.*)$;
    set $fsn /app.php;
    if (-f $document_root$fastcgi_script_name){
        set $fsn $fastcgi_script_name;
    }
    include conf.d/fastcgi.conf;
    fastcgi_param SERVER_ADMIN [email protected]$hostname;
}

location ~ /\. {
    deny all;
    access_log off;
    log_not_found off;
}

Who even switches between app.php and app_dev.php? Maybe hang dev on a subdomain or something else?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2014-08-14
@0neS

Actually...

/ - prod
/app_dev.php/ - dev

That is, for the dev environment, what you see app_dev.php is, as it were, normal. This is just for debugging.
As for the static - I do not understand what you mean. You just need to transfer it all in Resources and let assetic do it for you.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question