Phalcon Medianova CDN Integration
Phalcon is a high-performance PHP framework that is open source and available to developers with MVC logic. Unlike many PHP skeletons on the market, it is written as an extension to PHP with C.
In this document, we have described alternative ways to integrate between Phalcon and Medianova CDN.
Note: We recommend back up your files and database before they integrate.
First, create the Zone for account.
We recommend the first option to make the integration; define setStaticBaseUri.
<?php
$url = new Phalcon\Mvc\Url();
// Dynamic URIs remain on your origin server
$url->setBaseUri('/');
// Static resources go through MedianovaCDN
$url->setStaticBaseUri('http://your-origin-url.com/');
As an alternative to this path, use the collections and add a URL-prefix for CDN URL
<?php
$css = $this->assets->collection('header');
$scripts = $this->assets->collection('footer');
if ($config->environment == 'development') {
$css->setPrefix('/');
$scripts->setPrefix('/');
} else {
$cdnURL = 'http://your-cdn-url.com/';
$css->setPrefix($cdnURL);
$scripts->setPrefix($cdnURL);
}
$css->addCss('css/bootstrap.min.css')
->addCss('js/custom.css');
$scripts->addJs('js/jquery.js')
->addJs('js/bootstrap.min.js');
The last alternative offered
...
$cdnURL = 'http://your-cdn-url.com/';
$this->assets
->addCss($cdnURL.'css/custom.css', false);
...
Check your HTML source code learn whether (or not) load your assets from Medianova CDN.