Download the PHP package tihloh/prefab-permissions without Composer

On this page you can find all versions of the php package tihloh/prefab-permissions. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package prefab-permissions

Prefab Permissions

Prefab Permissions provides framework-independent authorization for PHP applications with user overrides, group inheritance and configurable permission defaults.

Define what an action means once, then resolve whether a user or subject may perform it.

Prefab Permissions is standalone. It does not require Prefab Database, Users, Auth, Logs, Routes, Laravel, or another framework package.

Requirements

Installation


1. Core model

Prefab resolves an effective permission through three levels:

A user-level override has the highest priority. If there is no override, group settings are considered. If neither supplies a decision, the permission definition's default is used.

This naturally supports tri-state behavior:

INHERIT means there is no override at that level; resolution continues downward.


2. Permission definitions

Definitions describe the permissions known by the application.

They may come from an inline PHP array, PHP configuration file, or JSON file.

JSON is also supported:

A definition may contain a stable ID plus human-friendly information such as a name, description and default value.

Conceptually:

Stable machine IDs should be used in application code; friendly names are for humans and interfaces.

Definitions may also include an optional group value for presentation:

Grouping is metadata only. It does not change authorization, inheritance, or scope resolution. Interfaces can retrieve grouped definitions with:


3. Checking permission

The common authorization question is:

This keeps authorization logic out of controllers and business code.

Instead of repeatedly implementing:

application code asks one stable question:


4. User overrides

Explicitly allow an action for one user:

Explicitly deny it:

Restore inheritance:

Clearing is different from setting false: false is an explicit deny, while clearing removes the override and lets lower levels decide.


5. Group inheritance

A user can inherit permissions from one or more groups according to the subject/group information supplied to the permission system.

Conceptually:

A user-specific override still takes precedence over inherited group behavior.

This makes it possible to manage most access at group level while handling exceptions for individual users.


6. Subject integration

Projects keep ownership of their user and group models.

For object-based resolution, a subject implements PermissionSubjectInterface:

Then:

Prefab does not require your model to extend a particular base class.


7. Custom storage

A custom PermissionStoreInterface can be supplied directly:

This makes the permission engine independent of one database implementation.

Conceptually:


8. Built-in database storage

The built-in database store accepts plain PDO or Prefab's DatabaseInterface:

The historical PdoPermissionStore name remains for compatibility. Internally it consumes DatabaseInterface; plain PDO is adapted automatically.


9. Automatic database configuration

A common centralized configuration is:

Or select a named Prefab Database connection:


10. Configuration resolution

Permissions follows the standard Prefab hierarchy:

This allows explicit standalone usage and low-configuration modular usage to coexist.


11. Database abstraction

Built-in database storage uses:

Database-specific DDL/upsert differences are isolated inside the built-in store for MySQL/MariaDB, PostgreSQL, SQLite and SQL Server.

The shared database interface deliberately remains small rather than turning Permissions into a database framework.


12. Prefab Users integration

Users can supply the identity/group information needed for authorization while Permissions remains responsible for the decision.

The modules remain independently installable.


13. Prefab Auth integration

Auth and Permissions answer different questions:

Typical flow:

Authentication success does not automatically imply authorization.


14. Prefab Routes integration

Authorization can be attached to routes rather than repeated inside every controller.

Conceptually:

An integration layer or middleware can then use Prefab Permissions to enforce the route's requirement.

This keeps routing and authorization separate while allowing them to cooperate.


15. Prefab Logs integration

When a compatible logger is available, permission changes can produce structured audit records automatically.

A technical permission operation such as:

can be rendered in a human-friendly form such as:

Friendly permission definition names improve audit readability without changing the stable permission ID used by code.


16. Laravel and framework compatibility

Laravel's own user model, Auth system and Gate system do not need to be replaced.

An adapter/bridge can expose the contracts Prefab needs while Laravel remains the host framework.

The same principle applies to other frameworks:

Prefab consumes capabilities rather than demanding control of the application.


17. Diagnostics

Use:

Diagnostics describe how important resources were resolved, including definitions, storage, table and database resources.

This is particularly useful when module-specific configuration, common configuration and automatic capability discovery coexist.


18. Practical small application

No other Prefab module is required.


19. Practical modular application

The resulting responsibilities remain clear:


20. Common authorization pattern

A controller or service can remain simple:

With routing middleware, the same check can be moved outside the controller entirely.


21. API quick reference

Common operations:

API Purpose
can() Resolve whether a subject has a permission
set() Set an explicit permission value
clear() Remove an override and restore inheritance
explain() Inspect configuration/resource resolution

Important concepts:

Component Purpose
permission definition Stable permission metadata/default
PermissionSubjectInterface Supplies subject ID and groups
PermissionStoreInterface Storage abstraction
PdoPermissionStore Built-in database-backed store
DatabaseInterface Shared database contract

22. Design philosophy

Prefab Permissions keeps authorization policy independent from user storage, authentication, routing and presentation.

The important rule remains:

Authentication identifies the user. Permissions decides what that user may do.

Prefab makes those responsibilities cooperate without forcing them into one monolithic framework.


23. Scoped permissions

Permission definitions can declare where the same permission may be granted:

The permission ID remains the same. Scope only limits where the grant is effective.

Global grants continue to use the normal API:

An organization-scoped grant uses:

The built-in database store keeps scoped grants separately from global grants in:

A scoped row identifies:

Resolution for a scoped check is:

This means a global grant applies in every organization, while an organization grant applies only when the application checks that organization's scope.

Prefab Permissions does not decide whether a document, user, request, or other resource belongs to an organization. The host application supplies the resource's scope:

Important APIs:

API Purpose
can(..., $scopeType, $scopeId) Resolve permission inside a scope
resolve(..., $scopeType, $scopeId) Resolve with source information
setScoped() Set a scoped allow/deny
clearScoped() Remove a scoped override
overridesForScope() Read scoped overrides
resolvedFor(..., $scopeType, $scopeId) Resolve all permissions inside a scope

Custom permission stores can opt into scoped authorization by implementing ScopedPermissionStoreInterface. Existing stores implementing only PermissionStoreInterface remain compatible for global permissions.


All versions of prefab-permissions with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
tihloh/prefab-core Version ^0.4 || ^0.5
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package tihloh/prefab-permissions contains the following files

Loading the files please wait ...