How To Install And Use CKEditor In Laravel

Do you want to install CKEditor in Laravel? CKEditor is a WYSIWYG HTML editor which allows us to write rich text formats. In this article, we show you how to install and use CKEditor in Laravel.

Why Need To Use CKEditor?

HTML provides a textarea element for writing description. But, textarea comes with some limitations. In textarea, it’s not easy and user-friendly to write other HTML elements like p, div, img, etc.

To overcome such limitations, we can use CKEditor which itself is a rich text editor. Our final output will look like the below screenshot.

Laravel CKEditor

As we are going to show how to use and install and CKEditor in Laravel, so we discuss about Laravel package for CKEditor library.

If you wish to use CKEdiotr apart from Laravel, then please check the official website for CKEditor.

Install CKEditor In Laravel

To install CKEditor in Laravel, open the command prompt in your project root directory and run the below command.

composer require unisharp/laravel-ckeditor

Above command will install CKEditor packages in your project’s vendor directory.

Next, open your config/app.php and place the below line to the providers array.


After the above steps, run the below command which copies some of the files and folders from ‘vendor\unisharp\laravel-ckeditor’ to ‘public\vendor\unisharp\laravel-ckeditor’.

php artisan vendor:publish --tag=ckeditor

How To Use CKEditor

At this stage, we have completed the steps for installing the CKEditor package. Now let’s see how to use the CKEditor.

Let’s say we have a textarea which should get replaced by CKEditor. To do so we are adding id ‘summary-ckeditor’ to the textarea.

<textarea class="form-control" id="summary-ckeditor" name="summary-ckeditor"></textarea>

Next, we need to include ckeditor.js file and write a JavaScript code which replaces textarea with CKEditor.

<script src="{{ asset('vendor/unisharp/laravel-ckeditor/ckeditor.js') }}"></script>
    CKEDITOR.replace( 'summary-ckeditor' );

That’s it! Above JavaScript code replaces textarea with the CKEditor.

We hope you understand how to install and use CKEditor in Laravel. For any questions or suggestions please leave a comment below.

If you liked this article, then please subscribe to our Youtube Channel for video tutorials.

12 thoughts on “How To Install And Use CKEditor In Laravel

  1. hello
    editor worked and save data in database , but when i want show text on front page . show html tag in page
    like ” some ting ”
    don’t hidden html tag .
    how i can fix that problem ?

  2. i use ck editor for in laravel but i have a problem is aries . all the tag are display in the view hoe to hide such display tab in my view page

  3. The Editor works okay but is saving the HTML tags as well to the Database. Is there a way to trim of the HTML tags when rendering the Database response in the blade view?

  4. i keep on getting this error
    Class ‘Unisharp\Ckeditor\ServiceProvider::class’ not found
    how can this be fixed?

Leave a Reply

Your email address will not be published. Required fields are marked *