PHPackages                             kreci-net/star-rating - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. kreci-net/star-rating

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

kreci-net/star-rating
=====================

Interactive star ratings with hover and click functionality in JavaScript/PHP

26PHP

Since Jul 6Pushed 2y ago1 watchersCompare

[ Source](https://github.com/KreCi-NET/star-rating)[ Packagist](https://packagist.org/packages/kreci-net/star-rating)[ RSS](/packages/kreci-net-star-rating/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Rating Script
-------------

[](#rating-script)

This rating script is a JavaScript/PHP component that allows users to rate an element using star icons. It provides interactive star ratings with hover and click functionality. The ratings are sent and retrieved using the `rating.php` script.

### Features

[](#features)

- Displays star icons that can be interacted with to rate an element.
- Updates the star colors dynamically based on the user's interaction.
- Sends the rating data to the server-side `rating.php` script for storage.
- Retrieves the initial rating from the `rating.php` script upon page load.
- One user is limited to mae only one rating per product ID with LocalStorage
- PHP API is protected from fake ratings with CSRF

### Demo

[](#demo)

Here you will find an implemented [star rating demo](https://dev.kreci.net/star-rating/vendor/kreci-net/star-rating/src/example.html). You may click on stars to submit the rating to the server and refresh the page to see average rating.

### Usage

[](#usage)

1. Include the JavaScript file `stars.js` in your HTML file (after the rating element):

```

```

2. Add the following HTML structure for the rating stars:

```

    &#9733;
    &#9733;
    &#9733;
    &#9733;
    &#9733;

```

Note: You can modify the number of stars by adding or removing `` elements.

3. The script can rate multiple elements and stores the data in CSV file (`ratings.csv` in the example). The ID of rated element is extracted from the current URL using patterns like `"domain.com/?123,somedescription"`, `"domain.com/index.html?123"` or `"domain.com/index.php?123"`. You can modify the pattern by editing the `getID()` function in the `stars.js` file. If the ID is not found in the URL, it uses the `const failOverID` from the `stars.js` file.

### Server-side Script (RatingManager.php)

[](#server-side-script-ratingmanagerphp)

The server-side script (`RatingManager.php`) is responsible for API request authorization, processing and storing the rating data. It receives the rating value and the ID of the item being rated through the URL parameters and stores those with StorageInterface object (StorageCSV class to store in the file in the example).

### Example

[](#example)

You can find a working example in the `example.html` and `rating.php` files in this repository. The example demonstrates how to integrate the rating script to enable star-based ratings for an element.

### Browser Compatibility

[](#browser-compatibility)

This script is compatible with modern web browsers, including Chrome, Firefox, Safari, and Edge. It requires JavaScript support to function properly.

### Dependencies

[](#dependencies)

This rating script has no external dependencies. It is built using native JavaScript/PHP.

### Known Issues

[](#known-issues)

- None at the moment.

Feel free to customize and modify the script to fit your specific requirements.

If you have any questions or encounter any issues, please feel free to open an issue in the repository or reach out for support.

Enjoy using the rating script!

License
-------

[](#license)

This project is licensed under the MIT License.

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity22

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/47452615728923e395aec2d543f734f9038e90adcbfd38fbe99c91a65bf2d602?d=identicon)[kreci](/maintainers/kreci)

---

Top Contributors

[![KreCi-NET](https://avatars.githubusercontent.com/u/128168962?v=4)](https://github.com/KreCi-NET "KreCi-NET (18 commits)")

### Embed Badge

![Health badge](/badges/kreci-net-star-rating/health.svg)

```
[![Health](https://phpackages.com/badges/kreci-net-star-rating/health.svg)](https://phpackages.com/packages/kreci-net-star-rating)
```

###  Alternatives

[yoast-seo-for-typo3/yoast_seo

Yoast SEO for TYPO3

521.6M9](/packages/yoast-seo-for-typo3-yoast-seo)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
