PHPackages                             dotkernel/dot-rbac-route-guard - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. dotkernel/dot-rbac-route-guard

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

dotkernel/dot-rbac-route-guard
==============================

Dotkernel RBAC Route guard component

0.2.0(6mo ago)02[1 issues](https://github.com/dotkernel/dot-rbac-route-guard/issues)MITPHPPHP ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0CI passing

Since Feb 27Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/dotkernel/dot-rbac-route-guard)[ Packagist](https://packagist.org/packages/dotkernel/dot-rbac-route-guard)[ Docs](https://github.com/dotkernel/dot-rbac-route-guard)[ RSS](/packages/dotkernel-dot-rbac-route-guard/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (14)Versions (3)Used By (0)

dot-rbac-route-guard
====================

[](#dot-rbac-route-guard)

`dot-rbac-route-guard` is Dotkernel's RBAC Route guard component.

Defines authorization guards that authorize users to access certain parts of an application based on various criteria. If the authorization service can be used to check authorization on a narrow level, the guards are meant to work as gateways to bigger parts of an application. Usually, you'll want to use both methods in an application for increased security.

Documentation
-------------

[](#documentation)

Documentation is available at: .

Badges
------

[](#badges)

[![OSS Lifecycle](https://camo.githubusercontent.com/c4e7860b27e8560606a31efc382724268fdbb403aaf9f925833e76c3915aa76d/68747470733a2f2f696d672e736869656c64732e696f2f6f73736c6966656379636c652f646f746b65726e656c2f646f742d726261632d726f7574652d6775617264)](https://camo.githubusercontent.com/c4e7860b27e8560606a31efc382724268fdbb403aaf9f925833e76c3915aa76d/68747470733a2f2f696d672e736869656c64732e696f2f6f73736c6966656379636c652f646f746b65726e656c2f646f742d726261632d726f7574652d6775617264)[![PHP from Packagist (specify version)](https://camo.githubusercontent.com/a7f6c01c5e4fd53a75c5ed0b1cf332d658ddcfe51e582214047a713d609a49f0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f646f746b65726e656c2f646f742d726261632d726f7574652d67756172642f302e322e30)](https://camo.githubusercontent.com/a7f6c01c5e4fd53a75c5ed0b1cf332d658ddcfe51e582214047a713d609a49f0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f646f746b65726e656c2f646f742d726261632d726f7574652d67756172642f302e322e30)

[![GitHub issues](https://camo.githubusercontent.com/2557f28d5ad6ef604c9f3701181e1dde0f076e7e335023ddebeb982b0eef23e4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f646f746b65726e656c2f646f742d726261632d726f7574652d6775617264)](https://github.com/dotkernel/dot-rbac-route-guard/issues)[![GitHub forks](https://camo.githubusercontent.com/8b9554fa5e8c0a7e7fdc1b7acd4c8122b854acaf4c2ad7a4d1fde87409b2e3e5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f646f746b65726e656c2f646f742d726261632d726f7574652d6775617264)](https://github.com/dotkernel/dot-rbac-route-guard/network)[![GitHub stars](https://camo.githubusercontent.com/b7cf14bdd9ab0c175f41b71d3a80643df3482e35e9e190472f0d25f877bb536e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f646f746b65726e656c2f646f742d726261632d726f7574652d6775617264)](https://github.com/dotkernel/dot-rbac-route-guard/stargazers)[![GitHub license](https://camo.githubusercontent.com/45db9c5e0df9a23b875b0187665d9a0f7538cfd5443e47bbe9585b660fac391f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f646f746b65726e656c2f646f742d726261632d726f7574652d6775617264)](https://github.com/dotkernel/dot-rbac-route-guard/blob/main/LICENSE.md)

[![Build Static](https://github.com/dotkernel/dot-rbac-route-guard/actions/workflows/continuous-integration.yml/badge.svg?branch=main)](https://github.com/dotkernel/dot-rbac-route-guard/actions/workflows/continuous-integration.yml)[![codecov](https://camo.githubusercontent.com/bb6edd6fdd34d8f66edd6e138220cfcae415ab1c0cf052423300afbe76f51771/68747470733a2f2f636f6465636f762e696f2f67682f646f746b65726e656c2f646f742d726261632d726f7574652d67756172642f67726170682f62616467652e7376673f746f6b656e3d41494e44594e76453550)](https://codecov.io/gh/dotkernel/dot-rbac-route-guard)[![PHPStan](https://github.com/dotkernel/dot-rbac-route-guard/actions/workflows/static-analysis.yml/badge.svg?branch=main)](https://github.com/dotkernel/dot-rbac-route-guard/actions/workflows/static-analysis.yml)

Installation
------------

[](#installation)

Run the following Composer command in your project's root directory:

```
composer require dotkernel/dot-rbac-route-guard
```

Please note that this library is built around the authorization service defined in `dotkernel/dot-rbac`. Running the above command will also install that library. You'll have to first configure `dot-rbac` before using this library.

Configuration
-------------

[](#configuration)

As with many Dotkernel libraries, we focus on the configuration-based approach of customizing the module for your needs.

After installing, merge `dot-rbac-route-guard`'s `ConfigProvider` with your application's config to make sure required dependencies and default library configuration are registered. Create a configuration file for this library in your 'config/autoload' folder.

### authorization-guards.global.php

[](#authorization-guardsglobalphp)

You can copy the below code or use the existing `authorization-guards.global.php.dist` to create your version of `authorization-guards.global.php`.

```
