Integrate Phalcon with Medianova CDN
Learn how to integrate Phalcon, a high-performance PHP framework, with Medianova CDN to serve static assets efficiently and enhance website performance.
Prerequisites
Integration Methods
1
<?php
$url = new Phalcon\Mvc\Url();
// Dynamic URIs remain on your origin server
$url->setBaseUri('/');
// Static resources go through Medianova CDN
$url->setStaticBaseUri('https://<CDN_ZONE_URL>/');
2
<?php
$css = $this->assets->collection('header');
$scripts = $this->assets->collection('footer');
if ($config->environment == 'development') {
$css->setPrefix('/');
$scripts->setPrefix('/');
} else {
$cdnURL = 'https://<CDN_ZONE_URL>/';
$css->setPrefix($cdnURL);
$scripts->setPrefix($cdnURL);
}
$css->addCss('css/bootstrap.min.css')
->addCss('css/custom.css');
$scripts->addJs('js/jquery.js')
->addJs('js/bootstrap.min.js');
3
<?php
$cdnURL = 'https://<CDN_ZONE_URL>/';
$this->assets
->addCss($cdnURL . 'css/custom.css', false);4
Troubleshooting
Problem
Cause
Solution
Last updated
Was this helpful?