Integrate ckeditor in codeigniter

Rakesh Sharma      16 Comments  

Integrate ckeditor in codeigniter :-

CKEditor is a text editor used by mostly sites and also under public license. it’s easy to use with php but need more effort to use ckeditor in codeigniter. i am trying to make it simple and sharing what i have done to integrate ckeditor or ckfinder in codeigniter site.
I am using both ckeditor and ckfinder in codeigniter to use images also. we need to include libraries and make controller and need some code to view for done.

Download With Example


1. Download code and extract and upload libraries and js(ckeditor and ckfinder) dir(if you don’t want to use js change path in controller to your uploaded dir)

2. Controller :- create a controller under controllers and add below code :-
Add a function in controller :-

function editor($path,$width) {
    //Loading Library For Ckeditor
    //configure base path of ckeditor folder 
    $this->ckeditor->basePath = base_url().'js/ckeditor/';
    $this->ckeditor-> config['toolbar'] = 'Full';
    $this->ckeditor->config['language'] = 'en';
    $this->ckeditor-> config['width'] = $width;
    //configure ckfinder with ckeditor config 

Add below code in which function you need to add ckeditor :-

$path = '../js/ckfinder';
$width = '850px';
$this->editor($path, $width);

3. View :- add below code to show ckeditor to view and set default value if you want.

<?php echo $this->ckeditor->editor('description',@$default_value);?>

Note :- After set all you need to change image save path

4. Change Image path :- for change image save path you must need to go to “js/ckfinder/config.php”

search for below code and change with your path:-

$baseUrl = '/ci/userfiles/';


  • Pradeep Sapkota

    Hello sir here is a problem with ckfinder. when the image icon in ckeditor is clicked and tried to browse server for file then the url appears like this but the js directory is in the root that is http;// how to fix this problem…please suggest.

    • tut snare

      Hi you need to setup correct path here

      $path = ‘../js/ckfinder';

      • wapjude

        its still not working

        • rakesh sharma

          Have you downloaded my example files and set it up and check it’s working? then integrate as same

  • Vitor de Sousa

    Here i received message “Unable to load the requested class: Ckeditor” =/

    My CI is 3.0 version

    • rakesh sharma

      You need to rename both ckeditor libraries according to CI 3 like first name of file is captital My_class. i will update my articles according CI 3

      • Vitor de Sousa

        Thanks! worked for me! :)
        Only problem is in preview images on editor… = dont show the images…

      • Vitor de Sousa

        What is the difference of the demo version to the paid (ck finder)?
        The demo version will stop working someday?

        • rakesh sharma

          can’t say about this, you can find details on their official site

          • Vitor de Sousa

            Thanks for ur support! :)

  • Demo Tester

    everything is working fine but m not able to upload an image. i don’t know how it works.

  • Paulo Henrique Amigoni


    Unable to load the requested class: Ckeditor

    CI 3

    • rakesh sharma

      If you are using CI3 all lib and controller file start name must be capital letter like Ckeditor.php so change that

  • Sarika Sharma

    I am using same code structure with ajax and CI3, and its working fine on first time, but when i again call the same it always shows an error instance already exist. If i destroy the instance before ajax call , it cant show the ckeditor instead showing plain textarea.
    Could you please help me?

    • rakesh sharma

      I havn’t used it with ajax, but i think you need to include all files(js and css) of ckeditor at run time. then call the ckeditor function to make visible.

  • Arief Budi Santoso

    I try with newest ckeditor but I have many error. Help Me. Or Can I use SDK ckeditor too?