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

Counter Bundle Laravel Package

pianosolo/counter-bundle

pianosolo/counter-bundle provides a simple counter abstraction for PHP applications, letting you increment, decrement, and read counts through a clean API. Use it to track views, downloads, or other metrics with minimal setup and reusable, testable counter logic.

View on GitHub
Deep Wiki
Context7

Getting Started

  • v1.1 adds fake count functionality for Doctrine entities via prePersist and preUpdate. This is an additive release; no breaking changes are indicated.
  • Install the package, publish/configure any fake-count settings if available, run required migrations for the count column, and clear Laravel config cache.
  • Look first at the README’s fake count section, the service provider’s Doctrine event listener/subscriber registration, and tests covering entity insert/update behavior.
  • First use case: enable fake counts in local/testing/seed data for Doctrine-managed entities so lists and dashboards show plausible counts without hand-writing fixtures.
  • If the app is Eloquent-only, verify whether v1.1 applies; the new lifecycle behavior is specifically Doctrine prePersist/preUpdate.

Implementation Patterns

  • Use fake counts for demo data and fixtures: let prePersist set the initial fake count, and preUpdate refresh it when the entity changes.
  • Gate the feature by environment, e.g. enable only in local/testing, and keep it disabled in production paths.
  • In apps with existing Doctrine lifecycle callbacks, check listener ordering. Decide whether fake count logic should run before or after your own count logic to avoid accidental overrides.
  • Test both insert and update flows explicitly. v1.1 wires two Doctrine events, so create-only tests miss half the behavior.
  • For deterministic tests, prefer a fixed seed or package extension point if one exists; otherwise avoid asserting exact fake count values in snapshots.
  • In mixed Eloquent/Doctrine apps, apply the package to Doctrine entities only and handle Eloquent counts manually through factories/model states.

Gotchas and Tips

  • Doctrine hooks do not fire for direct SQL, bulk updates, or Eloquent saves. If fake counts are missing, confirm the write path actually goes through Doctrine ORM lifecycle events.
  • preUpdate can overwrite legitimate counter changes. Keep fake counts disabled outside non-production environments and guard real counter update flows.
  • Clear Doctrine metadata cache and Laravel config cache after changing entity mappings or package config; stale metadata often looks like “the listener is not running.”
  • Avoid double-setting counts in factories/seeders if the package listener already assigns them. Remove manual fake values or make fixture logic conditional.
  • Check the count column’s type, nullability, and casts. Fake values still must satisfy database constraints.
  • Extension point: if the package exposes a fake-count generator/strategy binding, bind a deterministic implementation for tests. Otherwise wrap the entity listener or add an ordered Doctrine subscriber.
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.
adachsoft/changelog-linter
adachsoft/collection
payerurl/telegrambot-crypto-payment-instant-payout
dskripchenko/laravel-hybrid-search
riorizkyrainey/lara-ced
mehedimi/static-vel
zharp/zharp
nonsapiens/bigquery-model-sync
lgu-bayambang-ict-office/lgu-laravel-development-standards
andydefer/laravel-support
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel
draftsmaninc/draftsman
square-bit/laravel-volition
himito/laravel-mailman
htinlynn/genius-helper
maco-studios/hephaestus
adachsoft/php-code-style