dev-master
9999999-dev http://github.com/ideatosrl/StarRatingBundleSymfony Bundle for simple Star Rating System
MIT
The Requires
- php >=5.3.2
- doctrine/orm ~2.2,>=2.2.3
The Development Requires
symfony star-rating ideato
Symfony Bundle for simple Star Rating System
StarRatingBundle is a Symfony Bundle for easy star rating system. StarRatingBundle can be used with your own Javascript library but it also includes jQuery Raty plugin if you'd like to install and use the bundle as-it-is., (*1)
Install the bundle via Composer:, (*2)
composer require ideato/star-rating-bundle "dev-master"
Add the IdeatoStarRatingBundle to your application kernel:, (*3)
// app/AppKernel.php public function registerBundles() { return array( // ... new Ideato\StarRatingBundle\IdeatoStarRatingBundle(), // ... ); }
Update the database schema with Doctrine:, (*4)
app/console doctrine:schema:update --force
Include the routing configuration:, (*5)
#app/config/routing.yml _ideato_starrating: resource: "@IdeatoStarRatingBundle/Resources/config/routing.yml"
In order to include static files in case of you want to use jQuery Raty plugin included, you need to:, (*6)
Add the bundle within the allowed Assetic bundles:, (*7)
#app/config.yml assetic: #... bundles: [ IdeatoStarRatingBundle ]
Load static files:, (*8)
{% javascripts '//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js' '@IdeatoStarRatingBundle/Resources/public/jquery.raty.js' '@IdeatoStarRatingBundle/Resources/public/jquery.starrating.js' %} <script type="text/javascript" src="{{ asset_url }}"></script> {% endjavascripts %} {% stylesheets "@IdeatoStarRatingBundle/Resources/public/jquery.raty.css" filter="cssrewrite" %} <link rel="stylesheet" href="{{ asset_url }}" /> {% endstylesheets %}
Install the assets and regenerate static files:, (*9)
app/console assets:install web app/console assetic:dump
If you chose to use the jQuery plugin included, you simply need to render the star rating controller in your pages:, (*10)
{{ render( controller( "IdeatoStarRatingBundle:StarRating:displayRate", { contentId: post.id }) ) }}
You just need to customize the contentId
param according to the id of your element. The controller automatically will render the rating stars with the current score enabled.
Something like the following screenshot:, (*11)
, (*12)
In this way everything is already enabled and users can start to rate your resources., (*13)
You can completely rewrite the rating logic within the jquery.starrating.js. The easiest way is to copy and paste the file within your bundle and use your own Javascript file., (*14)
Symfony Bundle for simple Star Rating System
MIT
symfony star-rating ideato