Download the PHP package damianociarla/rating-bundle without Composer

On this page you can find all versions of the php package damianociarla/rating-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package rating-bundle

DCSRatingBundle

The DCSRatingBundle adds support for a rating system in Symfony2. Features include:

1) Installation

A) Download and install DCSRatingBundle

To install DCSRatingBundle run the following command

bash $ php composer.phar require damianociarla/rating-bundle

B) Enable the bundle

Enable the required bundles in the kernel:

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new DCS\RatingBundle\DCSRatingBundle(),
    );
}

2) Create your Vote and Rating classes

In this first release DCSRatingBundle supports only Doctrine ORM. However, you must provide a concrete Vote and Rating class. You must extend the abstract entities provided by the bundle and creating the appropriate mappings.

Rating

<?php
// src/MyProject/MyBundle/Entity/Rating.php

namespace MyProject\MyBundle\Entity;

use DCS\RatingBundle\Entity\Rating as BaseRating;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\ChangeTrackingPolicy("DEFERRED_EXPLICIT")
 */
class Rating extends BaseRating
{
    /**
     * @ORM\Id
     * @ORM\Column(type="string")
     */
    protected $id;

    /**
     * @ORM\OneToMany(targetEntity="MyProject\MyBundle\Entity\Vote", mappedBy="rating")
     */
    protected $votes;
}

Vote

<?php
// src/MyProject/MyBundle/Entity/Vote.php

namespace MyProject\MyBundle\Entity;

use DCS\RatingBundle\Entity\Vote as BaseVote;
use Doctrine\ORM\Mapping as ORM;

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

    /**
     * @ORM\ManyToOne(targetEntity="MyProject\MyBundle\Entity\Rating", inversedBy="votes")
     * @ORM\JoinColumn(name="rating_id", referencedColumnName="id")
     */
    protected $rating;

    /**
     * @ORM\ManyToOne(targetEntity="MyProject\UserBundle\Entity\User")
     */
    protected $voter;
}

3) Configure your application

# app/config/config.yml

dcs_rating:
    db_driver: orm
    base_path_to_redirect: / # when the permalink is not configured
    max_value: 5 # maximum value for the vote (stars displayed)
    model:
        rating: MyProject\MyBundle\Entity\Rating
        vote: MyProject\MyBundle\Entity\Vote

4) Import DCSRatingBundle routing

Import the bundle routing:

dcs_rating:
    resource: "@DCSRatingBundle/Resources/config/routing.xml"
    prefix:   /

5) Import stylesheet in your template

To import the stylesheet run the following command:

bash $ php app/console assets:install

and include the stylesheet in your template:

<link rel="stylesheet" href="{{ asset('bundles/dcsrating/css/rating.css') }}" />

5.1) Enable vote via ajax

To vote via ajax you have to include the script below after loading the jQuery library:

<script src="{{ asset('bundles/dcsrating/js/rating.js') }}"></script>

6) Showing rating and enabling vote

You can only vote the page you are in. You can not vote a page while you are on a different one. But you can show the rating of a page (read-only mode) in any page

Showing rating

You can show rating using stars without enabling voting:

{% include 'DCSRatingBundle:Rating:rating.html.twig' with {'id' : 'YOUR_UNIQUE_ID'} %}

This is useful if you have a list of items and want to show the rating of each item.

Enabling vote

To enable voting on a page use the following twig code:

{% include 'DCSRatingBundle:Rating:control.html.twig' with {'id' : 'YOUR_UNIQUE_ID'} %}

If you need to change the default user role for a specific page, add the role parameter:

{% include 'DCSRatingBundle:Rating:control.html.twig' with {'id' : 'YOUR_UNIQUE_ID', 'role' : 'ROLE_USER'} %}

If you need to change the permalink, add the permalink parameter, otherwise it will be stored the current route:

{% include 'DCSRatingBundle:Rating:control.html.twig' with {'id' : 'YOUR_UNIQUE_ID', 'permalink' : url('YOUR_ROUTE_ID')} %}

All versions of rating-bundle with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1
symfony/framework-bundle Version ^2.8 || ^3.0 || ^4.0
symfony/security-bundle Version ^2.8 || ^3.0 || ^4.0
symfony/twig-bundle Version ^2.8 || ^3.0 || ^4.0
twig/twig Version ^1.28 || ^2.0 || ^3.0
symfony/templating Version ^2.8 || ^3.0 || ^4.0
doctrine/orm Version ^2.6
doctrine/doctrine-bundle Version ^1.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package damianociarla/rating-bundle contains the following files

Loading the files please wait ....