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.
Create a Pull Zone before you start the Symfony CDN integration.
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']
Add your assets like this:
<img src="{{ asset('your-image.jpg', 'keycdn') }}" alt="Your Image" >
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.