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
=================

this package is used to manages permissions of users to access different parts of the app

1.0.1(10mo ago)0191MITPHPPHP ^8.2

Since May 5Pushed 10mo ago1 watchersCompare

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

READMEChangelog (2)Dependencies (1)Versions (4)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)

---

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: Migration

[](#step-2-migration)

run the migrate command

```
php artisan migrate
```

### Step 3: Define gates in the AppServiceProvider

[](#step-3-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\AuthorizeServiceProvider::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

32

—

LowBetter than 72% of packages

Maintenance54

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 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 ~63 days

Total

2

Last Release

315d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/67fc35394bd1e532d75cf3491aca86e6a5dd34da886f626939d1adcf4eb8aa07?d=identicon)[teksite](/maintainers/teksite)

---

Top Contributors

[![teksite](https://avatars.githubusercontent.com/u/149485086?v=4)](https://github.com/teksite "teksite (10 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

[lab404/laravel-impersonate

Laravel Impersonate is a plugin that allows to you to authenticate as your users.

2.3k16.4M48](/packages/lab404-laravel-impersonate)[santigarcor/laratrust

This package provides a flexible way to add Role-based Permissions to Laravel

2.3k5.4M43](/packages/santigarcor-laratrust)[overtrue/laravel-follow

User follow unfollow system for Laravel.

1.2k404.7k5](/packages/overtrue-laravel-follow)[codegreencreative/laravel-samlidp

Make your PHP Laravel application an Identification Provider using SAML 2.0. This package allows you to implement your own Identification Provider (idP) using the SAML 2.0 standard to be used with supporting SAML 2.0 Service Providers (SP).

263763.5k1](/packages/codegreencreative-laravel-samlidp)

PHPackages © 2026

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