How To Install CKEditor In Laravel

How to Install CKEditor in Laravel

How to Install CKEditor in Laravel

How to Install CKEditor in Laravel: Do you want to install CKEditor in your Laravel based application? In this blog article, I am going to show you how to install and use CKEditor in Laravel. so first thing first, we have to know about the Laravel package for the CKEditors library. If you wish to use CKEditor apart from Laravel, then please check the official website for CKEditor

For installing CKEditor in Laravel Application, open the command prompt in your project root directory and run the below command.

composer require unisharp/laravel-ckeditor

The above-written 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 in Laravel

And now, 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 that 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' );

Above JavaScript code replaces textarea with the CKEditor. Hope it will work for you.