Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Star Rating Bundle Laravel Package

sbyaute/star-rating-bundle

sbyaute/star-rating-bundle is a Symfony bundle that provides star rating components for displaying and collecting ratings in your applications. Add reusable rating widgets to templates and forms with minimal setup.

View on GitHub
Deep Wiki
Context7

Getting Started

Read this first: this is a Symfony bundle, not a Laravel package. There is no service provider, no facade, no config file registered with Laravel, and the templating is Twig. A Laravel developer cannot composer require this and expect it to work inside an App\ codebase without shimming. The realistic relationship a Laravel developer has with sbyaute/star-rating-bundle is as a reference implementation, not as a dependency.

The minimal sequence that actually works:

  1. composer require sbyaute/star-rating-bundle in a Symfony project (not Laravel).
  2. Register the bundle in config/bundles.php (Symfony Flex may do this automatically).
  3. Install its assets: php bin/console assets:install --symlink.
  4. Include the bundle's stylesheet/JS partial in your Twig template.
  5. Call the bundle's Twig helper (a star-rendering function/filter) with a numeric rating.

Where to look first when you vendor the code:

  • src/ — the bundle class and any Twig extension/filter (this is the actual API surface; it is small).
  • Resources/ (or templates/ + public/ on newer layouts) — the Twig template and the CSS/JS that render the stars.
  • composer.json — check the symfony/* version constraints; this tells you whether it is even installable on a modern Symfony, and hints at how old the code is.

First use case: a read-only display of an average rating on a product/review page. That is the lowest-risk, highest-value thing a star widget does, and it does not depend on the bundle's JS behavior at all — you can reproduce it with a Blade partial in ten minutes.

Implementation Patterns

Because the bundle is not Laravel-native, there are three honest ways to "leverage" it, in descending order of sanity:

1. Port it to a Blade component (recommended). The bundle's real value is the CSS and markup for a star row. Copy the stylesheet into resources/css/, extract the loop that renders filled/half/empty stars, and reimplement it as an anonymous Blade component:

{{-- resources/views/components/star-rating.blade.php --}}
@props(['value' => 0, 'max' => 5])
<div {{ $attributes->merge(['class' => 'star-rating']) }} role="img"
     aria-label="{{ number_format($value, 1) }} out of {{ $max }} stars">
  @for ($i = 1; $i <= $max; $i++)
    <span class="star {{ $value >= $i ? 'full' : ($value >= $i - 0.5 ? 'half' : 'empty') }}"></span>
  @endfor
</div>

This gives you Blade ergonomics, no Twig runtime, no Symfony bundle registration, and you control the accessibility markup.

2. Vendor the front-end assets only. If you like the visual treatment, copy just the JS/CSS out of the bundle's Resources/public (or public/) directory into resources/js / resources/css, wire them through Vite, and drive the widget with your own small Alpine or vanilla JS controller. You get the styling without inheriting the PHP integration glue.

3. Run it as a Symfony sidecar. Only makes sense if you actually have a Symfony service in the same product (e.g., a Symfony admin app). Then follow the standard bundle flow above and post ratings to a Laravel API endpoint from the Symfony front end.

Workflow tips regardless of path:

  • Treat the bundle's Twig helper signature as documentation for your component's props: (rating, max, readonly, size) is the shape you want.
  • Store the numeric rating server-side as a decimal or integer out of 100; round for display only. Never round-trip the rendered star count back into storage.
  • If you make it interactive, the widget should emit a number to a single endpoint (POST /reviews/{id}/rating), validated between:1,5 (or your max). Do not trust client-side star clicks.

Gotchas and Tips

  • No Laravel support, structurally. No StarRatingServiceProvider, no facade, no publishable config, no config/star-rating.php. Any tutorial implying php artisan vendor:publish --tag=star-rating is wrong for this package.
  • Twig asset paths will 404 in Laravel. The bundle references assets as @StarRatingBundle/... (Symfony's bundle-relative asset syntax). Laravel's asset() helper has no concept of bundles, so those references break immediately.
  • Maintenance risk is the headline. Zero stars, zero dependents, last release January 2023. There is essentially no community, no issue triage, and no evidence of a Symfony 6.4/7 compatibility pass. Pin nothing here; assume the code is frozen and treat it as a one-time copy.
  • Version constraints are the first thing to check. The composer.json require block will tell you the newest Symfony it tolerates. If it caps at Symfony 4/5, it won't install alongside modern dependencies and Composer will fail with a conflict — that failure is your signal to abandon path 1 and just port the CSS.
  • Symfony's asset install has no Laravel analogue. assets:install copies bundle public assets into public/bundles/. There is no vendor:publish equivalent, so copying files into resources/ manually is the correct move and you should commit them.
  • Accessibility is usually the weak point in these micro-bundles. Star rows built as <span> soup need role="img" plus an aria-label with the numeric value, or aria-hidden stars plus a visually-hidden text equivalent. If you go interactive, use real <button> elements with aria-pressed, and make sure keyboard users can set a rating. Check the bundle's markup before trusting it.
  • Half-star math is the classic bug. Comparing $value >= $i for full stars and $value >= $i - 0.5 for halves double-counts boundaries; normalize to a 0–100 integer scale, then floor against thresholds, or you'll ship off-by-one stars on exactly 2.5, 3.5, etc.
  • Extension point: because the bundle is tiny, the cheapest "extension" is a fork. If you need custom max, half-stars, or a different glyph, you are writing that logic yourself anyway — a resources/views/components/star-rating.blade.php file with 30 lines and full test coverage via a Blade render assertion beats a dependency you can't patch upstream.
  • Debugging checklist if you do try it in Symfony: bundle not in config/bundles.php → Twig function undefined; assets not installed → unstyled block of spans; cache not cleared after install → stale Twig extension list.

Bottom line for a Laravel developer: read the template and stylesheet, port them to a Blade component, and move on. The package earns its 0-score mostly by not being aimed at your ecosystem and not being maintained — neither of which your product needs to inherit.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
coleus/frame
thtg88/journalism
filagora/filagora-ai-forums
rlacerda83/query-parser
socialdept/atp-orm
cboxdk/laravel-assistant-client
socialdept/atp-resolver
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings