1
votes

I'm working on a Symfony2 app to replace a very large legacy system. During the transition period there will be times where the Symfony2 app and the legacy app will both be live at the same time and depending on the URI you hit Varnish will direct the request to the appropriate server. At the moment both apps place their assets under /css/ and /js/ which is going to cause us problems.

To solve this I want to change path the routing for the Symfony assets so they resolve under domain.com/symfony/css for example. Is there a way to do this in app_config.yml?

I've tried doing this on a per asset basis using this technique described in the docs: http://symfony.com/doc/master/cookbook/assetic/asset_management.html#controlling-the-url-used. The problem with that is that I have to find every stylesheet and javascript block and specify the URI manually. I've also had problems doing that where the URI generated changes every time a new file added.

1
You will have both apps in the same folder running? - cheesemacfly
@cheesemacfly - no, they will live on different servers under the same domain. Varnish is used to direct the request the right server. But we can't have both apps using /css/ for their stylesheets because then Varnish won't know which server to as the directory css could live on both servers. - Bendihossan

1 Answers

0
votes

You can set a custom url to be used for the output in the template, using..

{% javascripts '@AcmeBundle/Resources/public/js/*' output='symfony/js/main.js' %}
    <script src="{{ asset_url }}"></script>
{% endjavascripts %}

From: http://symfony.com/doc/2.1/cookbook/assetic/asset_management.html#controlling-the-url-used