Question

I´m trying to setup two different CDN´s in my Symfony2 project. With just one CDN, everything works fine with the following setup:

config.yml

templating:
    engines: ['twig']
    assets_base_urls:
        http: [http://cdn.blabla.com]
        ssl: []

After a few hours of research, I´ve seen there´s a way of setting up more than just one CDN:

config.yml

templating:
    engines: ['twig']
    assets_base_urls:
        http: []
        ssl: []
    packages:
        cdn:
            base_urls:
                http: ["http://cdn.blabla.com"]
                ssl: []
        cdn-static:
            base_urls:
                http: ["http://cdn-static.blabla.com"]
                ssl: []

When trying: {{ asset('/path/to/resource.ext','cdn') }}

It works really good, getting a URL like this: http://cdn.blabla.com/path/to/resource.ext

But when doing: {{ asset('/path/to/resource.ext','cdn-static') }}

It comes up with "An exception has been thrown during the rendering of a template ("There is no "cdn-static" asset package.")"

I´m using Symfony2 v2.0.15 and Twig v1.8.2

Any clue on what can it be happening?

Thanks & Regards,

Was it helpful?

Solution

config.yml

templating:
    engines: ['twig']
    assets_base_urls:
        http: []
        ssl: []
    packages:
        cdn:
            base_urls:
                http: ["http://cdn.blabla.com"]
                ssl: []
        cdn_static:
            base_urls:
                http: ["http://cdn-static.blabla.com"]
                ssl: []
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top