CodeIgniter Forums

Full Version: Integrating cloudways CDN to my Codeigniter project
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have set up CDN on Cloudways and was given a CDN Url. This I understand I need to add to my web application built on CodeIgniter.
[font=Arial,]I tried what solutions I could find on the web but it's either I'm not doing it right or it simply does not work.[/font]

[font=Arial,]I created a new helper file (cdn_helper.php) in my controller folder
[/font]


PHP Code:
function cdn_base_url($uri)
 
{
   $currentInstance =& get_instance();
   $keybasedcdnUrl $currentInstance->config->item('cdn_based_key_url');
   $extensions = array('css''js''jpg''jpeg''png''gif','pdf');
   $pathParts pathinfo($uri);
 
   if (!empty($keybasedcdnUrl) && in_array($pathParts['extension'],$extensions)) {
       return $keybasedcdnUrl $uri;
   }

   return $currentInstance->config->cdn_base_url($uri);



Then I added this line to my config file


PHP Code:
$config['cdn_based_key_url'] = 'https://457224-1431795-raikfcquaxqncofqfm.stackpathdns.com/'

It didn't work. However, I read something about setting my own prefix to extend the URL helper
PHP Code:
$config['subclass_prefix'] = 'MY_'
 
when I change the prefix to something like this 'ext.'; it gives an error.
please how do I properly integrate CDN?