PHPackages                             teksite/authorize - 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. teksite/authorize

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

teksite/authorize
=================

authorize package is used to manages permissions of users in Laravel framework to access different parts of the app

2.2.3(1mo ago)1371MITPHPPHP ^8.3

Since May 5Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/teksite/authorize)[ Packagist](https://packagist.org/packages/teksite/authorize)[ RSS](/packages/teksite-authorize/feed)WikiDiscussions main Synced today

READMEChangelog (8)Dependencies (5)Versions (15)Used By (1)

Extra laravel Package
=====================

[](#extra-laravel-package)

About
-----

[](#about)

This package is developed to manage accessibility of users to parts of laravel apps . The related model (like User) can have permissions directly or through its roles.

### Author

[](#author)

Sina Zangiband

### Contact

[](#contact)

- Alternate Website: [teksite.net](https://teksite.net)
- laratek.net [laratek.net](https://laratek.net)

---

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

[](#installation)

### Step 1: Install via Composer

[](#step-1-install-via-composer)

Run the following command in your CLI:

```
composer require teksite\authorize
```

### Step 2: generate migrations file

[](#step-2-generate-migrations-file)

run the migrate command

```
php artisan authorize:install
```

### Step 3: Migration

[](#step-3-migration)

run the migrate command

```
php artisan migrate
```

### Step 4: Define gates in the AppServiceProvider

[](#step-4-define-gates-in-the-appserviceprovider)

For laravel 5 or higher version, GatesServiceProvider is discovered automatically, so you don't need to do anything

#### Laravel 5.x and earlier

[](#laravel-5x-and-earlier)

If you are using Laravel 5.x or earlier, register the service provider in the `config/app.php` file under the `providers` array:

```
'providers' => [
    // Other Service Providers
    Teksite\Authorize\IconLaravelServiceProvider::class,
];
```

> **Note:** This step is not required for newer versions of Laravel (5.x and above).

---

Use
---

[](#use)

Add trait `\Teksite\Authorize\TraitsHasAuthorization` to any model that you want to implement authorization on it such as User model.

### Using in blades

[](#using-in-blades)

it can be used by own laravel directive for example for users with `can` directive:

```
@can('permission')
    \\ your codes
@endcan

```

or

```
@canany(['permission1' , permission2])
    \\ your codes
@endcanany

```

in the above code the permission is checked for the current (logged in) user if he/she has the permissions or his/her roles have the permission.

### syncing Permissions

[](#syncing-permissions)

to add/remove permissions directly to a User instances use

```
$user->syncPermissions(permissions: $permissions , detaching:$detaching  ])
```

- $permissions : should be arrays of permissions id or Permission instances.
- $detaching : should be a boolean parameter to determine new permissions should be appended to previous permissions or overwrite them.
- return void

### assign Roles

[](#assign-roles)

to assign roles directly to a User instances use

```
$user->assignRole(permissions: $roles ,detaching: $detaching  ]) :void
```

- $roles : should be arrays of roles id or Role instances.
- $detaching : should be a boolean parameter to determine new permissions should be appended to previous permissions or overwrite them.
- return void

### check having roles

[](#check-having-roles)

to check a user has roles

```
$user->hasRole(roles: $roles ,any : $any = true  ])
```

- $roles : should be array of roles id/title or Role instances.
- $any : should be a boolean parameter to determine if user has all roles or at least has one.
- return boolean

### check having permissions

[](#check-having-permissions)

to check a user has a permission directly or through its role

```
$user->hasPermission(permissions: $permission])
```

- $permission : should be permission id or permission title.
- return void

### get all permissions

[](#get-all-permissions)

to have all permissions of a user instance

```
$user->allPermissions()
```

- return collection|array

Add Role and Permission to the app
----------------------------------

[](#add-role-and-permission-to-the-app)

### permission entries

[](#permission-entries)

```
    protected $table = 'auth_permissions';

    protected $fillable = ['title', 'description'];
```

#### suggested rules

[](#suggested-rules)

use `Permission::rules()` or

```
[
 'title' => 'required|string|max:255|unique:auth_permissions,title',
 'description' => 'nullable|string|max:255',
]

```

### role entries

[](#role-entries)

```
    protected $table='auth_roles';

    protected $fillable =['title', 'description' ,'hierarchy'];
```

#### suggested rules

[](#suggested-rules-1)

use `Role::rules()` or

```
[
  'title'=>'required|string|max:255|unique:auth_roles,title',
  'description'=>'nullable|string|max:255',
  'permissions'=>'array|required',
  'permissions.*'=>'exists:auth_permissions,id',
  'hierarchy'=>'required','numeric',
];

```

---

Feel free to reach out if you have any questions or need assistance with this package!

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance93

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~33 days

Recently: every ~2 days

Total

13

Last Release

31d ago

Major Versions

1.0.1 → v2.x-dev2026-04-25

PHP version history (2 changes)1.0.0PHP ^8.2

v2.x-devPHP ^8.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/149485086?v=4)[teksite](/maintainers/teksite)[@teksite](https://github.com/teksite)

---

Top Contributors

[![teksite](https://avatars.githubusercontent.com/u/149485086?v=4)](https://github.com/teksite "teksite (29 commits)")

### Embed Badge

![Health badge](/badges/teksite-authorize/health.svg)

```
[![Health](https://phpackages.com/badges/teksite-authorize/health.svg)](https://phpackages.com/packages/teksite-authorize)
```

###  Alternatives

[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135224.7k7](/packages/statamic-rad-pack-runway)[jeremy379/laravel-openid-connect

OpenID Connect support to the PHP League's OAuth2 Server. Compatible with Laravel Passport.

59437.0k9](/packages/jeremy379-laravel-openid-connect)[api-platform/laravel

API Platform support for Laravel

58171.4k14](/packages/api-platform-laravel)[ecotone/laravel

Ecotone for Laravel — CQRS, Event Sourcing, Sagas, Durable Workflows, and Outbox on top of Laravel Queue, via PHP attributes.

21318.6k3](/packages/ecotone-laravel)[duncanmcclean/statamic-cargo

Comprehensive e-commerce addon for Statamic. Build bespoke e-commerce sites without the complexity.

3416.7k](/packages/duncanmcclean-statamic-cargo)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
