How To Install CKEditor In Laravel 8

Do you want to use CKEditor with Laravel 8? Today’s subject is how to install ckeditor in Laravel 8. I’ll walk you through the process of incorporating ckeditor into your most recent Laravel application.
You are aware that an editor is needed when writing an article. One of them is CKeditor, which should be used. It is well-known for its large number of plugins and active community.

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> <script>     
CKEDITOR.replace( 'summary-ckeditor' ); 

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

Happy Learning…