PHPackages                             crazedsanity/permission - 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. [Database &amp; ORM](/categories/database)
4. /
5. crazedsanity/permission

ActiveLibrary[Database &amp; ORM](/categories/database)

crazedsanity/permission
=======================

Library for handling permissions.

v0.1.2(9y ago)115MITPHPPHP &gt;=5.3.0

Since Mar 15Pushed 9y ago2 watchersCompare

[ Source](https://github.com/crazedsanity/permission)[ Packagist](https://packagist.org/packages/crazedsanity/permission)[ Docs](http://www.crazedsanity.com)[ RSS](/packages/crazedsanity-permission/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (3)Versions (3)Used By (0)

Permissions System
==================

[](#permissions-system)

This is a generic permissions system. The idea is to programatically allow/deny access to anything based on user, group, and "other" permissions.

If you understand Linux filesystem permissions, you should understand this system intrisically. It is based upon that system.

This system denies access by default: if a request is made for which there is no rule, permission is denied. This is a pretty basic system, lacking formal tie-ins to other tables. This simplicity is by design: avoiding any unnecessary linkage to other tables ensures maximum usability with minimal barrier to entry.

How It Works
============

[](#how-it-works)

Basics
------

[](#basics)

The thing that needs to have permissions assigned is stored in the `object` field. The user that owns it is assigned with the `user_id` field as an integer. The group that owns it is assigned with the `group_id` field as an integer. When requesting permission, the default is to deny: if no object matches the query, it is assumed that the permissions are `000`.

There is no concept of parent/child relationships, so each object is considered a stand-alone entity. It should be fairly easy to extend this system to accomodate that concept.

Perms Field
-----------

[](#perms-field)

The `perms` field is a number that indicates *user*, *group*, and *other* permissions, all together. So, given the value `321`, the `3` indicates *user* permissions, the `2` indicates group permissions, and the `1` indicates *other*.

Values for these fields are as follows:

- `1` is for *EXECUTE* (with `x` used for shorthand) privilege.
- `2` is for *WRITE* (with `w` used for shorthand) privilege.
- `3` is for *READ* (with `r` as shorthand) privilege.

The allowed privileges are added together to show what is allowed and what isn't. The breakdown is as follows

- `0` == `---` access denied (no read, no write, no execute)
- `1` == `--x` (no read, no write, +execute)
- `2` == `-w-` (no read, +write, no execute)
- `3` == `-wx` (no read, +write, +execute)
- `4` == `r--` (+read, no write, no execute)
- `5` == `r-x` (+read, no write, +execute)
- `6` == `rw-` (+read, +write, no execute)
- `7` == `rwx` full access (+read, +write, +execute)

So, to expand on that, you can read the following values as:

- `777` == full access to owner, group, and other (`rwxrwxrwx`)
- `532` == read+execute for owner, write+execute for group, write for other (`r-x-wx-w-`)
- `007` == no access to user/group, full access to other (`------rwx`)
- `700` == user has full access, but nobody else does (`rwx------`)

Order of Importance
-------------------

[](#order-of-importance)

It's somewhat important to know the order in which permissions are determined. So here it is.

1. *user*: if the `user_id` matches, the first set of permissions (the left-most set) are used.
2. *group*: if the `group_id` matches (and `user_id` does not), the group permissions are used.
3. *other*: if neither `user_id` nor `group_id` match, the other permissions are used.

Example Usage
=============

[](#example-usage)

*TODO*: put in some examples.

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity49

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

Total

2

Last Release

3346d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2e5c258da2d3360da7bc80c01e0a97ff96a036cef58f8a5434daf469ad7cc186?d=identicon)[crazedsanity](/maintainers/crazedsanity)

---

Top Contributors

[![crazedsanity](https://avatars.githubusercontent.com/u/1490894?v=4)](https://github.com/crazedsanity "crazedsanity (15 commits)")

---

Tags

phpsecuritydatabasemysqlsqlitepostgrespdopermissiondryoaoo

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/crazedsanity-permission/health.svg)

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

###  Alternatives

[aura/sqlquery

Object-oriented query builders for MySQL, Postgres, SQLite, and SQLServer; can be used with any database connection library.

4563.1M37](/packages/aura-sqlquery)[atlas/query

Object-oriented query builders and performers for MySQL, Postgres, SQLite, and SQLServer.

41253.7k7](/packages/atlas-query)[aura/sqlschema

Provides facilities to read table names and table columns from a database using PDO.

41240.2k4](/packages/aura-sqlschema)[tommyknocker/pdo-database-class

Framework-agnostic PHP database library with unified API for MySQL, MariaDB, PostgreSQL, SQLite, MSSQL, and Oracle. Query Builder, caching, sharding, window functions, CTEs, JSON, migrations, ActiveRecord, CLI tools, AI-powered analysis. Zero external dependencies.

816.0k](/packages/tommyknocker-pdo-database-class)[popphp/pop-db

Pop Db Component for Pop PHP Framework

1815.7k12](/packages/popphp-pop-db)

PHPackages © 2026

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