문제

For performance reasons, I want to deliver some of my files from a CDN.

Is it possible to configure the "asset" helper such that it automaticly sets something like "static1.xxxx.com/css/main.css" and "static2.xxxx.com/css/main.css"?

Perhaps something like:

{{ asset('css/main.css',static1) }}
도움이 되었습니까?

해결책

in in config.yml just add something like:

framework:
    templating:
      engines: ['twig']
      assets_base_urls:
        http: [http://yourcdn.com]

다른 팁

I think it is better to do something like:

templating:
    packages:
        cdn:
            base_urls:
                ssl: ['url']
                http: ['url']

That way you can do things like asset('yourfile', 'cdn') and also have multiple cdns (by specifying more packages).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top