Download the PHP package squareetlabs/laravel-teams-permissions without Composer

On this page you can find all versions of the php package squareetlabs/laravel-teams-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 laravel-teams-permissions

Squareetlabs/LaravelTeamsPermissions

Latest Stable Version PHP Version Require License

A comprehensive Laravel package designed for advanced team-based permission management in multi-tenant applications based on [Jurager/Teams]. This package provides a flexible and powerful system for organizing users into teams, assigning granular permissions through roles and groups, and managing entity-specific access controls.

Core Functionality:

Key Features

Requirements

Installation

1. Install the Package

2. Publish Configuration and Migrations

This will publish:

3. Configure the User Model

Add the HasTeams trait to your User model:

4. Run Migrations

⚠️ IMPORTANT: Always do backups before running migrations.

[!NOTE] If you wish to use custom foreign keys and table names, modify config/teams.php before running migrations.

5. Optional Configuration

Enable Caching

To improve performance, enable caching in .env:

Enable Audit Logging

To log all team actions:

[!NOTE] If you enable audit logging after running migrations, you'll need to publish and run the audit migration:

Enable REST API

To expose a REST API for team management:

Configuration

The configuration file config/teams.php contains all options:

Custom Models

Cache

Audit

See config/teams.php for all available options.

Basic Usage

Creating a Team

Adding Roles and Permissions

Adding Team Members

Checking Permissions

Teams

Available Methods

Users

The HasTeams trait provides the following methods:

Roles & Permissions

Creating Roles with Permissions

Wildcard Permissions

You can use wildcards for permissions:

Checking Permissions

Wildcard Permissions

You can enable wildcard permissions in configuration:

Users with these permissions will have full access to the team.

Abilities

Abilities allow specific permissions for individual entities.

Adding an Ability

Checking an Ability

Access Levels

Abilities use an access level system:

Level Value Description
DEFAULT 0 No explicit permissions
FORBIDDEN 1 Access denied
ROLE_ALLOWED 2 Allowed by role
ROLE_FORBIDDEN 3 Forbidden by role
GROUP_ALLOWED 4 Allowed by group
GROUP_FORBIDDEN 5 Forbidden by group
USER_ALLOWED 5 Specifically allowed to user
USER_FORBIDDEN 6 Specifically forbidden to user
GLOBAL_ALLOWED 6 Global permissions

Access is granted if the allowed level >= forbidden level.

Groups

Groups allow organizing users with shared permissions.

Creating and Managing Groups

Global Groups

Groups without team_id are global and apply to all teams:

Middleware

The package provides middleware for route protection.

Configuration

Middleware is automatically registered as role, permission, and ability.

Usage in Routes

OR Operations

AND Operations

Blade Directives

The package includes Blade directives for permission checks in views:

Policies

The package integrates with Laravel's Policy system.

Generate a Policy

This generates a policy extending TeamPolicy:

Using the Policy

REST API

If you enable the REST API, you'll have access to complete endpoints for team management.

Enable API

Available Endpoints

Authentication

The API requires Sanctum authentication:

Artisan Commands

The package includes several useful commands:

Team Management

Permission Management

Utilities

Caching

The caching system significantly improves permission check performance.

Configuration

Clear Cache

Or programmatically:

Audit Logging

The audit system logs all important team actions.

Enable Audit

Audited Events

Query Logs

[!NOTE] If you enable audit logging after running migrations, you'll need to run:

Events

The package fires events for important actions:

Available Events

Validation

The package includes validation rules:

Usage Examples

Blog System with Teams

Multi-tenant SaaS Application

Testing

The package includes factories and seeders for testing:

Troubleshooting

Error: "Model class for key user not found"

Make sure your User model is configured in config/teams.php:

Error: "AuditTableMissingException"

If you enable audit logging after running migrations:

Or disable audit logging in config/teams.php:

Cache Not Updating

Clear cache manually:

API Documentation

Classes and Methods

HasTeams Trait

Methods available on User model:

HasMembers Trait

Methods available on Team model:

PermissionCache Service

AuditService Service

TeamPolicy Base Class

Contributing

Contributions are welcome. Please:

  1. Fork the project
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Changelog

See CHANGELOG.md for the full list of changes.

License

This package is open-sourced software licensed under the MIT license.

Support

For support, please open an issue on GitHub.

Authors


All versions of laravel-teams-permissions with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-json Version *
illuminate/support Version ^8.0|^9.0|^10.0|^11.0|^12.0
illuminate/http Version ^8.0|^9.0|^10.0|^11.0|^12.0
illuminate/bus Version ^8.0|^9.0|^10.0|^11.0|^12.0
illuminate/mail Version ^8.0|^9.0|^10.0|^11.0|^12.0
illuminate/queue Version ^8.0|^9.0|^10.0|^11.0|^12.0
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 squareetlabs/laravel-teams-permissions contains the following files

Loading the files please wait ...