2

Is there some examples to implement this? Don't show nothing on my page.

{% include 'FOSCommentBundle:Thread:async.html.twig' with {'id': 'foo'} %} 

I don't understand how to place this code and what will show on my page.

And when i place this on my config.yml

    assetic:
         bundles: [ "FOSCommentBundle" ]   

Creates an error:

Unrecognized option "assetic" under "fos_comment".

My configuration:

fos_comment: db_driver: orm class: model: comment: BackEndBundle\Entity\Comment thread: BackEndBundle\Entity\Thread

assetic: bundles: [ "FOSCommentBundle" ]

Pillow
  • 103
  • 2
  • 9
  • Thanks for your edit. Specify one problem at time it's the best way to get a fast help and for us to understand where the problem is. – gp_sflover May 09 '17 at 14:40
  • Did you follow this https://github.com/FriendsOfSymfony/FOSCommentBundle/blob/master/Resources/doc/1-setting_up_the_bundle.md guide? – Ali Niaz May 09 '17 at 14:43
  • I never used FOSCommentBundle but seems from the error that the `assetic` otpion doesn't exist under the `fos_comment` sector. Have you double checked all the integration process to be sure to followed correctly the docs? – gp_sflover May 09 '17 at 14:45
  • @AliNiaz yes i followed all the documentation from github but didn't work : ( – Pillow May 09 '17 at 14:47
  • Are you using also FOSUserBundle? – gp_sflover May 09 '17 at 14:48
  • @gp_sflover Im new using symfony. I need to implement comments on my site to interact users. But i don't know how to do it manualy so i tried to use this bundle because to create users and admin them i used FOSUsersBundle. – Pillow May 09 '17 at 14:49
  • So you've followed the [Step: Integration with FOSUserBundle](https://github.com/FriendsOfSymfony/FOSCommentBundle/blob/master/Resources/doc/6-integration_with_fosuserbundle.md)? – gp_sflover May 09 '17 at 14:53
  • Exist other bundle to create comments on symfony and works with Symfony 3 ? I'm really lost. There isn't much information on Friendsofsymfony github. – Pillow May 09 '17 at 14:53
  • @gp_sflover yes i did :S – Pillow May 09 '17 at 14:54
  • check your AsseticBundle configurations follow this link http://symfony.com/doc/current/reference/configuration/assetic.html – Ali Niaz May 09 '17 at 15:18
  • Unfortunately I never used this bundle and I haven't much time now but after a fast looking to the docs it doesn't seem much complicated. Symfony have a moderate learning curve that mostly depends by your general programming knowledge. Maybe you will need a full tutorial example but this is off-topic here. – gp_sflover May 09 '17 at 15:19
  • @AliNiaz Thanks that solves one problem. Still showing nothing about comments but the error has gone. I didn't notice that Symfony3 doesn't give AsseticBundle by default. – Pillow May 09 '17 at 15:26
  • can you show us the code area where you made changes during configuration? – Ali Niaz May 09 '17 at 15:36
  • @AliNiaz Which area ? I just followed the steps on tutorial. No i dont get any error but the text dont apear. I'don't know if i need to place something else on my view or just only this {% include 'FOSCommentBundle:Thread:async.html.twig' with {'id': 'foo'} %} . – Pillow May 09 '17 at 15:44
  • check browser console for any js related errors. – Ali Niaz May 09 '17 at 15:59
  • @AliNiaz i checked but there is no error of js. – Pillow May 09 '17 at 16:27
  • please run command assets:install, than check for console js errors in browser as I have mentioned earlier. – Ali Niaz May 09 '17 at 17:01
  • @AliNiaz like this ? https://gyazo.com/dcf53ed72f8fd45f843eaabaf4205cc3 – Pillow May 09 '17 at 17:14
  • yes like this and also run doctrine:schema:update after doctrine:cache:clear-metadata – Ali Niaz May 09 '17 at 17:30
  • @AliNiaz Cmd said nothing to update. Im not sure if this should create table comment and thread on my database but i dnt got it. – Pillow May 09 '17 at 17:33
  • did you run doctrine:cache:clear-metadata first? – Ali Niaz May 09 '17 at 17:34
  • @AliNiaz yes i did : ( – Pillow May 09 '17 at 17:36
  • I have managed to make this bundle work for me, I will post all the parts of code in the answer below please follow the steps to achieve this. – Ali Niaz May 09 '17 at 17:51

1 Answers1

3

I assume you have configure the bundle and have created the require classes like this

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use FOS\CommentBundle\Entity\Comment as BaseComment;

/**
 * @ORM\Entity
 * @ORM\ChangeTrackingPolicy("DEFERRED_EXPLICIT")
 */
class Comment extends BaseComment
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * Thread of this comment
     *
     * @var Thread
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Thread")
     */
    protected $thread;
}

And Thread.php like this

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use FOS\CommentBundle\Entity\Thread as BaseThread;

/**
 * @ORM\Entity
 * @ORM\ChangeTrackingPolicy("DEFERRED_EXPLICIT")
 */
class Thread extends BaseThread
{
    /**
     * @var string $id
     *
     * @ORM\Id
     * @ORM\Column(type="string")
     */
    protected $id;
}

In your config.yml, you will now have something like this

fos_comment:
    db_driver: orm
    class:
        model:
            comment: AppBundle\Entity\Comment
            thread: AppBundle\Entity\Thread

run the following commands

doctrine:cache:clear-metadata
doctrine:schema:update --force

After this you will have tables in the database for the entities Now include this at top of the template

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>

where you've included this

{% include 'FOSCommentBundle:Thread:async.html.twig' with {'id': 'foo'} %}

Clear both dev and prod cache after this step. PS: I have selected the doctrine ORM method

Ali Niaz
  • 312
  • 3
  • 10