Download the PHP package vimatech/laravel-membership without Composer
On this page you can find all versions of the php package vimatech/laravel-membership. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download vimatech/laravel-membership
More information about vimatech/laravel-membership
Files in vimatech/laravel-membership
Package laravel-membership
Short Description Polymorphic memberships for Laravel.
License MIT
Informations about the package laravel-membership
Laravel Membership
Polymorphic memberships for Laravel.
Laravel Membership lets you attach members and roles to any Eloquent model — organizations, teams, projects, workspaces, communities, or anything else.
It answers who belongs to what and with which role — nothing more.
Why Laravel Membership?
Most Laravel apps eventually need to answer:
- Who belongs to this organization?
- What role does this user have in this project?
- Can we prevent removing the last owner?
- Can the same membership logic work for teams, projects and workspaces?
Laravel Membership provides a small backend-only layer for that.
Feature Matrix
| Feature | Supported |
|---|---|
| Polymorphic memberships | ✅ |
| Enum roles | ✅ |
| Role hierarchy | ✅ |
| Guards (last owner, etc.) | ✅ |
| Events | ✅ |
| Scopes | ✅ |
| Soft deletes | ✅ |
| Policy helpers | ✅ |
| Invitations | ➕ (use Laravel Invitation) |
| Permissions | ❌ (use Spatie) |
| Billing | ❌ |
| UI | ❌ |
Laravel Membership vs Permissions
Laravel Membership manages:
- who belongs to what
- which role they have
Permission packages (like Spatie) manage:
- what users can do
They are complementary, not competing.
Use Cases
- SaaS organizations
- Teams
- Projects
- Workspaces
- Communities
- Collaborative apps
- Multi-tenant applications
- Agency client portals
- Internal company tools
Installation
Requirements
- PHP 8.3+
- Laravel 11, 12 or 13
Publish config
Publish migrations
Usage
Make a model have members
Make a model act as a member
Create a roles enum (optional)
You can also use plain strings — enums are optional.
Add a member
Remove a member
Update a role
Check membership
Query members
Query memberships from member side
Scopes
Policy helpers
Facade (optional)
Complete Example
Events
The following events are dispatched:
| Event | When |
|---|---|
MemberAdded |
After a member is added |
MemberRemoved |
After a member is removed |
MemberRoleUpdated |
After a member's role is changed |
Each event contains the Membership instance and an optional $actor.
Guards
Guards are configurable protections in config/membership.php:
When prevent_self_demotion or prevent_role_escalation are enabled, pass an $actor:
Configuration
Soft Deletes
By default, removing a member permanently deletes the row. To keep membership history instead, enable soft deletes:
-
Set
'soft_deletes' => trueinconfig/membership.php - If your app is already in production, create a migration:
If you enable
soft_deletesbefore running your initial migration, the column is added automatically.
Once enabled:
Philosophy
Laravel Membership is intentionally minimal.
The package focuses on:
- Memberships
- Roles
- Role hierarchy
- Membership guards
Design principles:
- Backend-only, UI agnostic
- No auth assumptions
- No User model assumptions
- No permissions system
- No billing assumptions
- Enum-friendly roles
- Polymorphic by default
- Laravel-native API
- Clean and testable actions
It does not aim to become a permissions framework, a billing system, a UI framework, or a complete SaaS platform.
Possible Future Extensions
- Invitation bridge
- Audit logs
- Membership expiration
- Filament integrations
- Livewire components
Future extensions may be released as separate packages to keep the core package small and focused.
Testing
Contributing
Contributions are welcome.
Please ensure:
- Tests pass (
composer test) - PHPStan passes (
composer analyse) - Code style is formatted with Pint (
composer format)
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our Security Policy for reporting vulnerabilities.
License
The MIT License (MIT). Please see License File for more information.
Credits
Built and maintained by Vimatech. Created by Adel Zemzemi.
All versions of laravel-membership with dependencies
illuminate/database Version ^11.0|^12.0|^13.0
illuminate/support Version ^11.0|^12.0|^13.0
illuminate/contracts Version ^11.0|^12.0|^13.0