sfSimpleCommentPlugin - 0.9.2

Comments feature plugin.

You are currently browsing
the website for symfony 1

Visit the Symfony2 website

« Back to the Plugins Home


Forgot your password?
Create an account



advanced search
Information Readme Releases Changelog Contribute
Show source

sfSimpleComment plugin (for symfony 1.4)

The sfSimpleCommentPlugin is a symfony plugin that provides basic comments feature for all doctrine models. It's a great bedrock for any more complex comments solutions.

It gives you the basic generic model (comment) and the module (controller and component; frontend only right now) to make any model commentable in a minute.


  • Install the plugin (via a package)

    symfony plugin:install sfSimpleCommentPlugin
  • Install the plugin (via a Subversion checkout)

    svn co http://svn.symfony-project.com/plugins/sfSimpleCommentPlugin plugins/sfSimpleCommentPlugin
  • Activate the plugin in the config/ProjectConfiguration.class.php

    class ProjectConfiguration extends sfProjectConfiguration
      public function setup()
  • Rebuild your model/classes

    symfony doctrine:build --all
  • Enable required module in your settings.yml (optional)

         enabled_modules:      [default, sfSimpleComment]
  • Clear you cache

    symfony cc

Use in your application

To use sfSimpleCommentPlugin in symfony application:

  • Enable ability to comment for selected models in app.yml (in other words add requried config entries to your app.yml)

        commentable_types: [YourCommentableModel, YourCommentableModel2]
  • Inlcude comments list and comment form components on selected pages (like showSuccess template of selected models)

    <?php include_component('sfSimpleComment', 'index', array('commentable' => $yourModelInstance)); ?>
    <?php include_component('sfSimpleComment', 'new', array('commentable' => $yourModelInstance)); ?>
  • That's all, enjoy :)

(Extend) Convenient connection between comments and commentable models

For each commentable type you can add comment inherited class in project scheme.yml. That will make commenting more strict on code level and gives you possibilty to set default object_type value if you are creating comments out of the default sfSimpleComment module. From other point of view that gives you ability to set neat alias' between commentable type and comment model in doctrine:

  • Example:

        extends: sfSimpleComment
        type: column_aggregation
        keyField: object_type
        keyValue: Article
          local: object_id
          foreign: id
          type: one
          foreignType: many
          onDelete: CASCADE
          foreignAlias: Comments
          alias: Article