filagora/filagora-memberships
Filagora Memberships is a Laravel package for adding membership plans and subscriber management to your application. Define tiers, assign memberships to users, and control access to features or content through a simple, flexible API. Keep plan logic clean, extensible, and easy to integrate with exis...
This is an early (v0.1.x) package, so treat the public API as unstable and pin the version in composer.json.
composer require filagora/memberships
php artisan vendor:publish --tag=memberships-config
php artisan vendor:publish --tag=memberships-migrations
php artisan migrate
config/memberships.php (plans/tiers, gating defaults) and the migrations (membership/subscription tables).register()), and let the package's membership targeting rule participate in announcement targeting.Gate checks in policies and middleware. Prefer a single membership-check abstraction (policy, gate, or middleware) over scattering hasActiveMembership() calls through controllers. Blade directives are convenient for hiding UI, but always enforce server-side in middleware/policies.
Lazy registry resolution. Since v0.1.1 the membership announcement targeting rule is registered the first time the forums rule registry is used, not during application boot. Follow the same discipline in your own code: resolve the registry inside a handler, not in a provider's register() or boot(). If you need it at boot, wrap it in a deferred provider or a closure so it only runs when actually consumed.
Custom or overriding rules. Filagora\Memberships\Forums\MembershipRule is non-final as of v0.1.1, so you can extend it to add host-specific targeting logic (e.g. plan-specific announcements) while reusing its membership matching. Keep the constructor signature compatible, since the parent depends on the host's access checker.
Rule precedence. The registry keeps a membership rule that was registered first. If you want your own implementation to win, register it before anything resolves the registry for the first time — ideally in a dedicated provider that runs early and does not itself trigger registry resolution.
Testing. Bind a fake access checker in TestCase::setUp() so tests never depend on real membership data. For feature tests of announcements, assert on the targeted audience rather than on the rule object. Add one test that boots the app without an access checker bound to lock in the v0.1.1 behaviour (the app should start; only resolving the registry should fail).
Console, queue, and static analysis. Any context that builds the container — queue workers, scheduled commands, PHPStan/Larastan bootstraps — should have the access checker bound if it might touch forum rules. The v0.1.1 fix means a bare bootstrap no longer crashes, but jobs that actually evaluate targeting still need the binding.
Versioning discipline. With 0.x, read the changelog on every minor bump. Keep integration points (your rule subclass, registry registration, access checker binding) isolated in one provider so upgrades are a single-file change.
membership key is not overwritten by the package if you registered one first. That is useful for overrides but surprising when debugging: if your custom rule isn't taking effect, check when it was registered relative to the first registry use.MembershipRule. Override only the targeting decision, call parent:: where appropriate, and avoid adding required constructor arguments — the registry instantiates rules, so a changed signature may break resolution.php artisan config:clear. Lazy registration is not affected by config caching, but plan/tier definitions read at resolution time are.app()->bound(...)), confirm nothing resolved the registry earlier and cached a registry without the rule, and confirm the announcement's targeting key matches membership.migrate in staging first."filagora/memberships": "0.1.*" with changelog review is safer than ^0.1 if you subclass MembershipRule, since the constructor contract is not yet guaranteed.How can I help you explore Laravel packages today?