- How does Horus differ from spatie/laravel-permission for Laravel role/permission management?
- Horus builds on spatie/laravel-permission but adds batch operations for roles/permissions and auto-generates permissions from Laravel policies (e.g., `PostPolicy::update`). It’s ideal for teams needing bulk setup or policy-driven permissions without manual configuration.
- Can I use Horus without installing spatie/laravel-permission first?
- No, Horus requires spatie/laravel-permission as a dependency. Install it first via `composer require spatie/laravel-permission`, publish its config, and run migrations before adding Horus.
- Does Horus support Laravel 13? Will it break in future updates?
- Horus officially supports Laravel 10–12. Laravel 13+ is untested, so minor breaking changes could occur if adopted. Monitor the GitHub repo for updates or check compatibility before upgrading.
- How do I generate permissions from a model’s policy class?
- Enable Sphinx support in `config/horus.php` and set the `policy_namespace` (e.g., `App\Policies`). Run `php artisan horus:generate-permissions` to auto-create permissions based on your policy methods like `update`, `delete`, etc.
- What’s the performance impact of batch role/permission creation?
- Horus uses Spatie’s underlying database operations, which are optimized for bulk inserts. For large-scale systems (e.g., 10K+ roles), test with your dataset—caching (e.g., Laravel’s permission cache) can mitigate overhead.
- Can I assign permissions to roles dynamically at runtime?
- Yes, Horus extends Spatie’s role-permission assignments. Use `Role::find(1)->givePermissionTo('edit-post')` or batch methods like `Role::find(1)->syncPermissions(['edit-post', 'delete-post'])` for dynamic updates.
- Are there alternatives to Horus for Laravel RBAC with policy integration?
- For policy-based permissions, consider `spatie/laravel-permission` alone (manual setup) or `entrust` (older, less maintained). Horus is unique in combining Spatie’s stability with batch operations and Sphinx’s policy integration.
- How do I migrate existing roles/permissions from another package to Horus?
- Export your current roles/permissions (e.g., via Spatie’s `Role::all()` or raw SQL), then use Horus’s batch methods to recreate them. Example: `Role::create(['name' => 'admin']); Role::find(1)->givePermissionTo('manage-users');`
- Does Horus work with multi-tenancy (e.g., SaaS platforms)?
- Yes, Horus supports multi-tenancy if you use Spatie’s `hasMany` role-permission relationships per tenant. Combine it with packages like `stancl/tenancy` for tenant-aware role assignments.
- How do I test Horus in a CI pipeline? What edge cases should I cover?
- Test role/permission creation, policy permission generation, and batch assignments. Edge cases include concurrent role updates, permission cache invalidation, and edge cases like empty policy classes or duplicate permissions.