- What does laravel-liberu/roles actually do?
- It provides role and permission management for Laravel Liberu applications. The package covers role CRUD, assigning permissions to roles, and syncing roles to users through a configurable, modular structure. It is built on Laravel's native authorization layer rather than replacing it.
- How do I install laravel-liberu/roles in a Laravel app?
- Install it with Composer using composer require laravel-liberu/roles, then follow the Liberu installation steps for publishing configuration and running migrations. Because it is part of the Laravel Liberu ecosystem, you should also confirm that the required Liberu core packages are installed and compatible. Check the repository README for the exact publish and migrate commands for your release.
- Which Laravel versions are supported by laravel-liberu/roles?
- The supported Laravel range is defined by the package's Composer constraints, so check composer.json for the exact versions allowed by your release. The package is designed around Laravel's authorization layer, including gates and permissions. Confirm compatibility against your application's Laravel version before upgrading.
- Does it integrate with Laravel gates, policies, and the can method?
- Yes. The package is built on Laravel's authorization layer, so role and permission checks work through the framework's normal authorization flow. You can use familiar checks such as Gate::allows and the user can method once roles and permissions are assigned. Policies remain the right place for model-specific rules, while this package supplies the role and permission data behind them.
- How do I assign permissions to a role?
- Permissions are assigned to roles through the package's role management structure, which stores the relationship between roles and permissions. In practice, you attach the required permissions when creating or updating a role via the provided CRUD flow. Then users receive effective permissions through their assigned roles.
- How does user-role syncing work?
- The package includes user-role syncing so a user's roles can be updated in a controlled way rather than edited manually in multiple places. Syncing typically replaces or reconciles the user's role assignments according to the submitted role set. Review the package configuration and service classes for the exact sync behavior in your version.
- Is the package configurable, and should I publish its config?
- Yes, it is described as configurable and modular. You should publish the package configuration if you need to adjust table names, model mappings, or other integration details. Use the repository instructions for your release, since publish tags and config keys can change between versions.
- Can I use laravel-liberu/roles outside a full Laravel Liberu application?
- It is primarily designed for Laravel Liberu applications and may depend on Liberu conventions or core packages. Using it in a standalone Laravel app is possible only if those dependencies are satisfied and the modular structure fits your application. If you want a lightweight standalone role package, evaluate whether the Liberu integration overhead is acceptable.
- How should I test roles and permissions in my application?
- Use Laravel's testing tools with a fresh database, create the roles and permissions your scenario needs, assign them to a user, and assert the expected authorization result. Prefer assertions against Gate or the user can method so you test the effective permission behavior rather than internal tables. Include tests for denied access as well as allowed access.
- How is laravel-liberu/roles maintained, and what are the alternatives?
- It is maintained as part of the Laravel Liberu package ecosystem, so check the repository releases and issue tracker for current activity and compatibility notes. A common alternative is spatie/laravel-permission, which is widely used in standalone Laravel projects. Choose laravel-liberu/roles when you want Liberu-style role CRUD and user-role syncing integrated with Laravel's authorization layer.