phpsymfony-2.5

Integrating CKeditor to my symfony 2.5


I download the ckeditor and would like to integrate that in my website which is built using Symfony 2.5, reading from the documentation it seems that all third party code should go inside the vendordirectory but then what? is that all? if i put all ckeditor code inside the vendor directory then what about the js files? dont they go inside a view? I have been searching online for a solution to this and most of them seem to be pointing towards using a bundle available online which i would like to avoid and leave that as my last resort.

I have used ckeditor before with custom php and this is my first time with symfony framework, I know we are supposed to create a textarea and assign it an id or a class but what i am looking for is steps before this, for example

1) Add ckeditor to vendor

2) add it to auto load or something

3) ...

I will really appreciate if someone can direct me on how to do it?


Solution

  • I am not sure if this is the right way to do it but this is what worked for me.

    1. I ended up copying the ckeditor files inside bundle/Resources/public/js
    2. Install the assets by running the command php app/console assets:install
    3. In your twig file add the <script src="{{ asset('bundles/blog/js/ckeditor.js') }}"></script> (please make sure to change this to your bundle name)
    4. Assign class ckeditor to your textarea field, this is how I did it {{ form_widget(form.description, { 'attr': {'class': 'ckeditor'} }) }}

    and I can see the editor on my screen enter image description here

    If anyone else has a better idea (other than using a bundle) I would love to hear from them