Support

Find answers, guides, and tutorials to supercharge your content delivery.

Symfony CDN Integration

Updated on October 4, 2018

This tutorial describes how to integrate KeyCDN into the MVC PHP framework Symfony. The integration is very easy with the following option. All you need is to set the base URL and reference it later when you load your assets.

  1. Create a Pull Zone before you start the Symfony CDN integration.

  2. Define the base URL in your app/config/config.yml config file.

    • Symfony 2.6

      framework:
      templating:
          packages:
              keycdn:
                  base_urls:
                      http: ['http://cdn.foobar.com']
                      ssl:  ['https://secure.foobar.com']
      
    • Symfony 2.7

      framework:
      assets:
          packages:
              keycdn:
                  base_urls: ['http://cdn.foobar.com', 'https://secure.foobar.com']
      
  3. Add your assets like this:

    <img src="{{ asset('your-image.jpg', 'keycdn') }}" alt="Your Image" >
    
  4. Check in the HTML source code if the URL of your assets is pointing correctly to KeyCDN.

Did you find another integration approach with Symfony we should mention here? Contact us and we will add it.

Supercharge your content delivery 🚀

Try KeyCDN with a free 14 day trial, no credit card required.

Get started
KeyCDN uses cookies to make its website easier to use. Learn more