Weave Code
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

Laravel Love Laravel Package

cybercog/laravel-love

Add reactions, likes, votes, and other “feelings” to any Eloquent model with Laravel Love. Flexible, enterprise-ready system inspired by GitHub/Facebook/Slack reactions. Includes migrations and APIs to make models reactable in minutes.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Core Use Case Alignment: Perfect fit for social engagement features (likes, dislikes, custom reactions) on Eloquent models. Mimics platforms like GitHub, Reddit, or YouTube.
  • Weighted Reaction System: Supports nuanced reactions (e.g., 1-5 stars, sentiment scores) via configurable weights/rates, enabling advanced use cases like:
    • Sentiment analysis (e.g., "thumbs-up" = +1, "meh" = 0, "thumbs-down" = -1).
    • Enterprise voting (e.g., weighted approval systems).
  • Extensibility: Custom reaction types (e.g., "laugh," "confused," "heart") via ReactionType contracts. Supports both binary (like/dislike) and multi-value systems.
  • Aggregation: Pre-built counters for real-time metrics (e.g., "1.2K reactions") via ReactionTotal and ReactionCounter models, reducing query load.

Integration Feasibility

  • Laravel Ecosystem: Native integration with Eloquent, Events, Queues, and Artisan. Minimal boilerplate for basic use (e.g., use \Cog\Laravel\Love\Traits\Reacterable;).
  • Database Schema: Auto-generates migrations for:
    • love_reactions (user-reaction-content links + weights).
    • love_reaction_types (customizable reaction labels).
    • love_reactant_reaction_totals (aggregated counts).
  • Model Agnostic: Works with any Eloquent model (e.g., Post, Comment, Product). Supports polymorphic relationships if needed.
  • API-Friendly: Built-in methods for:
    • reactTo($reactant, $type, $rate) (create/update reactions).
    • hasReactedTo($reactant, $type) (check reactions).
    • reactions() (fetch user reactions).

Technical Risk

Risk Area Assessment Mitigation
Migration Complexity Breaking changes in v8/v9 (e.g., weighted system, schema shifts). Upgrade path requires love:upgrade-v7-to-v8 Artisan command. Test upgrade in staging; use UPGRADING.md as a checklist.
Performance at Scale Aggregation jobs (IncrementReactionAggregatesJob) run asynchronously but may lag under high write loads. Monitor queue backlogs; consider batching or caching aggregates (e.g., Redis).
Customization Overhead Advanced features (e.g., custom weights, reaction types) require config tweaks or model overrides. Document customization in a ReactionConfig service class.
Legacy Compatibility Dropped support for Laravel <9/PHP <8.0. If using older versions, fork or use v7.x. Audit dependencies; plan for upgrade if on unsupported stack.
Testing Gaps Limited test coverage for edge cases (e.g., concurrent reactions, rate limits). Add integration tests for critical paths (e.g., Reacter::reactTo race conditions).

Key Questions

  1. Reaction Granularity:

    • Do you need binary (like/dislike) or weighted (1-5 stars) reactions? Weighted requires additional config (ReactionType::setWeight()).
    • Example: ReactionType::create(['name' => 'love', 'weight' => 1])->save();
  2. Aggregation Strategy:

    • Will you use the built-in ReactionTotal counters, or implement custom caching (e.g., Redis) for performance?
    • Note: Aggregates are updated asynchronously via jobs.
  3. User Identity:

    • How are users identified? Default assumes Auth::id(), but supports custom Reacter models (e.g., TeamMember).
    • Example: User::find(1)->reactTo($post, 'love');
  4. Rate Limits:

    • Should reactions be rate-limited (e.g., "1 reaction per minute")? Not built-in; may need middleware (e.g., throttle).
  5. Frontend Integration:

    • How will reactions be displayed? The package provides backend logic; UI components (e.g., buttons, counters) must be built separately.
    • Example: {{ $post->reactions()->count() }} likes.
  6. Analytics:

    • Do you need reaction analytics (e.g., "most reacted posts")? The package supports raw queries but may require custom reporting.
  7. Multi-Tenancy:

    • If using tenancy (e.g., Laravel Nova), ensure reactant_id/reacter_id are scoped per tenant.

Integration Approach

Stack Fit

  • Laravel Versions: Officially supports Laravel 9–13 (PHP 8.0–8.5). Tested with Laravel 13.4 in v10.2.2.
  • Database: Works with MySQL, PostgreSQL, SQLite (default). Supports custom table names via config.
  • Queue Systems: Uses Laravel Queues for async aggregation. Compatible with Redis, database, etc.
  • Testing: Built with PHPUnit; Dockerized test environment available.

Migration Path

Step Action Tools/Commands
Prerequisite Check Verify Laravel/PHP compatibility. If on v<9, fork or use v7.x. composer show laravel/framework
Installation Add package and run migrations. composer require cybercog/laravel-love php artisan migrate
Model Setup Mark models as "reactable" (e.g., Post). php artisan make:model Post --reactable Or manually: use Reacterable;
Reaction Types Define custom reaction types (e.g., "love," "haha"). ReactionType::create(['name' => 'love'])->save();
Configuration Tweak weights, defaults, or table names in config/love.php. config/love.php
Upgrade (if needed) Run upgrade command for major versions (e.g., v7→v8). php artisan love:upgrade-v7-to-v8
Testing Validate reactions, aggregates, and edge cases. php artisan test Or Docker: docker compose exec php85 composer test

Compatibility

  • Existing Code:
    • Minimal impact if using Eloquent. Existing models can be retrofitted with Reacterable trait.
    • Avoids global side effects (e.g., no automatic reaction tables on all models).
  • Third-Party Packages:
    • Conflicts unlikely, but test with packages that modify Eloquent (e.g., Spatie’s Activitylog).
    • Example: Ensure Observers don’t interfere with ReactionObserver.
  • Frontend:
    • No direct coupling, but ensure API endpoints (e.g., POST /reactions) align with frontend calls.

Sequencing

  1. Phase 1: Core Integration

    • Install package, run migrations, and mark key models (e.g., Post, Comment) as reactable.
    • Implement basic reactions (e.g., "like" button).
  2. Phase 2: Customization

    • Add custom reaction types (e.g., "clap," "heart").
    • Configure weights (e.g., love = +1, dislike = -1).
  3. Phase 3: Aggregation & Performance

    • Enable async aggregates via queues.
    • Optimize counters with caching (e.g., Redis) if needed.
  4. Phase 4: Analytics/Reporting

    • Build queries for reaction trends (e.g., "top posts by reaction type").
    • Integrate with tools like Laravel Scout or custom dashboards.
  5. Phase 5: Scaling

    • Monitor queue performance; adjust batch sizes in RebuildReactionAggregatesJob.
    • Consider read replicas for high-traffic reaction queries.

Operational Impact

Maintenance

  • Dependencies:
    • Laravel core (tight coupling). Major Laravel upgrades may require package updates.
    • PHP 8.0+ required; PHP 8.5 tested in v10.2.2.
  • Updates:
    • Follow UPGRADING.md for breaking changes (e.g., v8→v9 schema shifts).
    • Monitor for Laravel version drops (e.g.,
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.
codraw/framework-extra-bundle
codraw/messenger
codraw/security
codraw/mailer
codraw/contracts
codraw/profiling
codraw/dependency-injection
codraw/tester
codraw/core
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony