PHPackages                             memcrab/access - 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. memcrab/access

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

memcrab/access
==============

PHP Access lib for memCrab Core API

1.4.0(4y ago)150.0k↓36.4%MITPHPPHP &gt;=7.1

Since Feb 16Pushed 4y ago1 watchersCompare

[ Source](https://github.com/Memcrab/Access)[ Packagist](https://packagist.org/packages/memcrab/access)[ Docs](http://memcrab.com)[ RSS](/packages/memcrab-access/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (15)Used By (0)

PHP Router as Composer Library
==============================

[](#php-router-as-composer-library)

### Status

[](#status)

[![Build Status](https://camo.githubusercontent.com/c0978938e2894b616310b49b48055db5c5c42b7cf691e58463f029b083d1f94e/68747470733a2f2f7472617669732d63692e6f72672f6e6f6f6e65686f732f6163636573732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/noonehos/access)[![Total Downloads](https://camo.githubusercontent.com/7117e56f34f1abe8b35a9837008544e4405969b99ffa3725cd83453c54b84444/68747470733a2f2f706f7365722e707567782e6f72672f6d656d637261622f6163636573732f646f776e6c6f616473)](https://packagist.org/packages/memcrab/access)[![Latest Stable Version](https://camo.githubusercontent.com/55326a4ff75c96e52577895c670105608a14b33953577e41ee74dbc18cbe582b/68747470733a2f2f706f7365722e707567782e6f72672f6d656d637261622f6163636573732f76657273696f6e)](https://packagist.org/packages/memcrab/access)[![Latest Unstable Version](https://camo.githubusercontent.com/8f059437aca6ccc0fc19f082c8a55f1a044646726bfdaedcdbda39950b58b0a0/68747470733a2f2f706f7365722e707567782e6f72672f6d656d637261622f6163636573732f762f756e737461626c65)](//packagist.org/packages/memcrab/access)[![License](https://camo.githubusercontent.com/3d44cd612c81ed60d0d54713ce3e2755fbd8a129948d94e0b94de4aa0b5b858a/68747470733a2f2f706f7365722e707567782e6f72672f6d656d637261622f6163636573732f6c6963656e7365)](https://packagist.org/packages/memcrab/access)[![composer.lock available](https://camo.githubusercontent.com/64dee54e45828f279f42c1a167c623c46bcf3f2acaee4fc1168b38c7a7b30a87/68747470733a2f2f706f7365722e707567782e6f72672f6d656d637261622f6163636573732f636f6d706f7365726c6f636b)](https://packagist.org/packages/memcrab/access)

It's lightweight php access rights module.

Features
--------

[](#features)

- Support services, actions and roles that need to be controlled by access rights
- Support access groups that combaine multiple services and actions for access all of them to some role
- All configurations is array based and it may be simple YAML file
- Allows you to check role access to any Service/Action
- Allows to check role access to group of actions
- Allows you to get all groups that available for current role
- Allows to use rights matrix by roles or by services or by access groups it's allows you to check any rights by simple isset() using only keys of array.
- Used High performance yaml parse throw using updated pecl yaml-ext 2.0.0 for php 7.0
- Strict standart coding with full Typing of params and returns (by php 7.1)
- PSR-4 autoloading compliant structure
- Unit-Testing with PHPUnit
- Easy to use to any framework

Install
-------

[](#install)

`composer require memcrab/access`

Dependencies
------------

[](#dependencies)

php extension YAML:

- for Ubuntu/Debian

```
- apt-get update
- apt-get install php-pear
- apt-get install php-dev
- apt-get install php-xml php7.0-xml
- apt-get install libyaml-dev
- pecl channel-update pecl.php.net
- pecl install yaml-2.0.0

```

- for OS X

```
- brew install php71 --with-pear
- brew install autoconf
- touch $(brew --prefix php71)/lib/php/.lock && chmod 0644 $(brew --prefix php71)/lib/php/.lock
- pecl install yaml-2.0.0

```

Usage
-----

[](#usage)

- init Access: `new memCrab\Access()`
- load rules: `->loadRules(array $rules)`
    - $rules - Rules from yaml file for exaple
- run checks: `->checkRights(string $service, string $action, string $userRole)`
    - $service - name of service (or maybe controller)
    - $action - name of action
    - $userRole - name of user role

Yaml Config Example
-------------------

[](#yaml-config-example)

```
contentView:
  roles: [guest, user, admin]
  services:
    post: [get]
    product: [get]
    index: [get]
    catalog: [filter]
contentManage:
  roles: [admin]
  services:
    post: [add, save, delete]
    product: [add, save, delete]
```

Run Example
-----------

[](#run-example)

```
require_once __DIR__ . "/../vendor/autoload.php";
use memCrab\Exceptions\FileException;
use memCrab\File\Yaml;
use memCrab\Access\Access;
use memCrab\Exception\AccessException;

try {
  $Yaml = new Yaml();
  $rules = $Yaml->load("config/rules.yaml", null)->getContent();

  $Access = new Access();
  $Access->loadRules($rules);

  if(!$Access->checkRights("post", "save", "admin")) throw AccessException("Access Denie.", 401);
    // do all your work
}
catch(AccessException $error){
  $Response = new \YourResponseClass();
  $Response->setErrorResponse($error);
}

$Response->sendHeaders();
$Response->sendContent();
```

---

**MIT Licensed**

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 88% 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 ~129 days

Recently: every ~375 days

Total

14

Last Release

1697d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/796d3f8f9559efb1274cdced887fdee9d259b0fdb60cef468bdc6674864d77bf?d=identicon)[Memcrab](/maintainers/Memcrab)

---

Top Contributors

[![oleksandr-diudiun](https://avatars.githubusercontent.com/u/2369309?v=4)](https://github.com/oleksandr-diudiun "oleksandr-diudiun (22 commits)")[![katsan-misha](https://avatars.githubusercontent.com/u/36279060?v=4)](https://github.com/katsan-misha "katsan-misha (3 commits)")

---

Tags

phpaccesslibmemcrab

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/memcrab-access/health.svg)

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

PHPackages © 2026

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