{"id":22864101,"url":"https://github.com/statix-php/sentra","last_synced_at":"2026-02-22T14:05:01.687Z","repository":{"id":267919499,"uuid":"902738503","full_name":"statix-php/sentra","owner":"statix-php","description":"A lightweight Laravel roles and permissions package using Backed Enums","archived":false,"fork":false,"pushed_at":"2024-12-13T22:12:37.000Z","size":31,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-14T11:56:17.729Z","etag":null,"topics":["laravel","permissions","roles","roles-permissions"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/statix-php.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"Statix"}},"created_at":"2024-12-13T07:04:59.000Z","updated_at":"2024-12-13T21:56:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"deecfa18-f603-4380-be7c-269081cca984","html_url":"https://github.com/statix-php/sentra","commit_stats":null,"previous_names":["statix-php/sentra"],"tags_count":1,"template":false,"template_full_name":"spatie/package-skeleton-laravel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/statix-php%2Fsentra","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/statix-php%2Fsentra/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/statix-php%2Fsentra/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/statix-php%2Fsentra/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/statix-php","download_url":"https://codeload.github.com/statix-php/sentra/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248878020,"owners_count":21176242,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["laravel","permissions","roles","roles-permissions"],"created_at":"2024-12-13T11:19:08.320Z","updated_at":"2025-10-18T22:16:08.789Z","avatar_url":"https://github.com/statix-php.png","language":"PHP","readme":"# Sentra for Laravel\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/statix/sentra.svg?style=flat-square)](https://packagist.org/packages/statix/sentra)\n\nA lightweight Laravel roles and permissions package using Backed Enums.\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require statix/sentra\n```\n\nYou should publish the config file with the following command:\n\n```bash\nphp artisan vendor:publish --tag=\"sentra\"\n```\n\nThis is the contents of the published config file:\n\n```php\nreturn [\n\n    /**\n     * The backed enum class that will be used to define your roles.\n     */\n    'roles_enum' =\u003e 'App\\Enums\\Roles',\n\n    /**\n     * The backed enum class that will be used to define your permissions.\n     */\n    'permissions_enum' =\u003e 'App\\Enums\\Permissions',\n\n];\n```\n\n## Usage\n\nTo get started, create two string backed Enums - one of your roles and one for your permissions.\n\n```bash\nphp artisan make:enum \"App\\Enums\\Roles\" --string\nphp artisan make:enum \"App\\Enums\\Permissions\" --string\n```\n\nIf you create your enums in a different namespace or different name, be sure to update the `roles_enum` and `permissions_enum` in the `sentra.php` config file.\n\n\nThen add the `AsRole` trait to your `Roles` enum. \n\n```php\n\u003c?php\n\nnamespace App\\Enums;\n\nuse Statix\\Sentra\\Attributes\\Roles\\Describe;\nuse Statix\\Sentra\\Concerns\\AsRole;\n\nenum Roles: string\n{\n    use AsRole;\n}\n```\n\nAnd add the `AsPermission` trait to your `Permissions` enum.\n\n```php\n\u003c?php\n\nnamespace App\\Enums;\n\nuse Statix\\Sentra\\Attributes\\Permissions\\Describe;\nuse Statix\\Sentra\\Concerns\\AsPermission;\n\nenum Permissions: string\n{\n    use AsPermission;\n}\n```\n\nYou are now ready to start defining your roles and permissions.\n\n```php\n\u003c?php\n\nnamespace App\\Enums;\n\nuse Statix\\Sentra\\Attributes\\Roles\\Describe;\nuse Statix\\Sentra\\Concerns\\AsRole;\n\nenum Permissions: string\n{\n    use AsPermission;\n\n    #[Describe(\n        label: 'Create Posts', \n        description: 'Create new posts'\n        roles: [\n            Roles::SuperAdmin,\n            Roles::Admin\n        ]\n    )]\n    case CreatePosts = 'create-posts';\n\n    #[Describe(\n        label: 'Edit Posts', \n        description: 'Edit existing posts'\n        roles: [\n            Roles::SuperAdmin,\n            Roles::Admin,\n            Roles::StandardUser\n        ]\n    )]\n    case EditPosts = 'edit-posts';\n\n    #[Describe(\n        label: 'Delete Posts', \n        description: 'Delete existing posts'\n        roles: [\n            Roles::SuperAdmin,\n            Roles::Admin\n        ]\n    )]\n    case DeletePosts = 'delete-posts';\n}\n```\n\n```php\n\u003c?php\n\nnamespace App\\Enums;\n\nuse Statix\\Sentra\\Attributes\\Roles\\Describe;\nuse Statix\\Sentra\\Concerns\\AsRole;\n\nenum Roles: string\n{\n    use AsRole;\n\n    #[Describe(\n        label: 'Super Admin', \n        description: 'The highest level of access'\n    )]\n    case SuperAdmin;\n\n    #[Describe(\n        label: 'Admin', \n        description: 'Admin level access'\n    )]\n    case Admin = 'admin';\n\n    #[Describe(\n        label: 'Standard User', \n        description: 'Standard user access'\n    )]\n    #[Describe('User')]\n    case StandardUser = 'user';\n}\n```\n\n## Testing\n\n```bash\ncomposer test\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\nPlease review [our security policy](../../security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n- [Wyatt Castaneda](https://github.com/)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n## Todo \n\n- make it easier to assign a super-admin role, kinda of like the before method in laravel policies","funding_links":["https://github.com/sponsors/Statix"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstatix-php%2Fsentra","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstatix-php%2Fsentra","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstatix-php%2Fsentra/lists"}