Download the PHP package muhammad-nawlo/multitenant-plugin without Composer

On this page you can find all versions of the php package muhammad-nawlo/multitenant-plugin. 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 multitenant-plugin

Filament Multitenant Plugin

A comprehensive multitenant plugin for Filament that integrates seamlessly with stancl/tenancy and spatie/laravel-permission to make multitenant applications easier to build and manage. This plugin provides complete tenant management with role-based permissions and beautiful Filament interfaces.

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Features

Installation

  1. Install the package via Composer:

  2. Install required dependencies (if not already installed):

  3. Publish required configurations:

  4. Run the setup command:

  5. Add the plugin to your Filament panel:

Installation Notes

Quick Start

Making Resources Tenant-Aware

Use the TenantAwareResource trait in your Filament resources:

Making Resources Tenant-Aware with Permissions

Use the TenantAwareResource trait for resources that need both tenancy and permissions:

Making Pages Tenant-Aware

Use the TenantAwarePage trait in your Filament pages:

Making Pages Tenant-Aware with Permissions

Use the TenantAwarePage trait for pages that need both tenancy and permissions:

Making Models Tenant-Aware

Add the BelongsToTenant trait to your models:

Configuration

The plugin provides extensive configuration options in config/multitenant-plugin.php:

Usage

Tenant Management

The plugin provides a complete tenant management interface:

Tenant Dashboard

Access the tenant dashboard to see:

API Methods

The traits provide several useful methods:

Commands

Setup Command

This command will:

Generate Tenant Permissions

This command will:

Force Setup

Force setup even if tenancy is already configured.

Grant All Permissions to Super Admin

This command grants all permissions in the database to the super admin role (configurable via MULTITENANT_PLUGIN_SUPER_ADMIN_ROLE in your .env).

Generate All Permissions for a Resource

This command generates all standard permissions (view, create, update, delete, etc.) for a given Filament resource.

Generate Permissions and Policies for Panels/Resources

This command generates all standard permissions (and optionally policy stubs) for resources registered to your Filament panels, similar to Shield's generator.

Options:

Example:

This will generate all permissions and policy stubs for all resources in all panels.

Middleware

The plugin includes middleware for tenant initialization:

Advanced Usage

Custom Tenant Identification

You can customize how tenants are identified by modifying the middleware:

Error Handling

The plugin is designed to be robust and handle cases where dependencies aren't available:

Custom Tenant Data

Store additional tenant data in the data column:

Tenant-Specific Permissions

The plugin automatically creates tenant-specific permissions. For example:

This allows you to control access per tenant:

Using the Permission Service

Testing

Troubleshooting

Common Issues

  1. "Target class [Stancl\Tenancy\TenancyManager] does not exist"

    • Make sure you have installed stancl/tenancy
    • Run composer require stancl/tenancy
    • Follow the tenancy package setup instructions
    • The plugin will work without tenancy, but tenant-specific features will be disabled
  2. Setup command fails

    • Ensure you have write permissions to your app directory
    • Check that the User model exists and is writable
    • Run php artisan multitenant:setup --force to overwrite existing files
    • The command will create missing directories automatically
  3. Permissions not working

    • Ensure spatie/laravel-permission is properly installed and configured
    • Run php artisan permission:create-role super_admin to create a super admin role
    • Then run php artisan multitenant:generate-permissions --all
    • Check that your User model has the HasRoles trait
  4. "Class not found" errors in TenantResource

    • This usually happens when page namespaces are incorrect
    • The plugin now uses fully qualified namespaces to avoid this issue
    • If you encounter this, try running the setup command again
  5. Syntax errors in User.php after setup

    • The setup command now uses regex to properly insert the trait
    • If you encounter syntax errors, check the User model file
    • Run php artisan multitenant:setup --force to fix the User model
  6. Plugin not working in test environment
    • This is expected behavior as the plugin requires a proper Laravel application
    • The plugin includes null checks and try-catch blocks for test environments
    • Features will be gracefully disabled in test contexts

Debugging

To debug issues with the plugin:

Getting Help

If you're still experiencing issues:

  1. Check the stancl/tenancy documentation
  2. Check the spatie/laravel-permission documentation
  3. Open an issue on the GitHub repository with detailed error messages

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

TenantManagementPanel

This plugin provides a dedicated Filament panel for tenant management, accessible at /tenant-management.

Features

Dependencies

Access Control

Testing

  1. Install this package in a Laravel app with Filament, stancl/tenancy, and spatie/laravel-permission installed.
  2. Ensure your user has the super_admin role (using Spatie/Permission or Shield).
  3. Visit /tenant-management in your browser.
  4. Only super admins should be able to access and manage tenants.

Plugin Manager Class


All versions of multitenant-plugin with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
filament/filament Version ^3.0
spatie/laravel-package-tools Version ^1.15.0
stancl/tenancy Version ^3.7
spatie/laravel-permission Version ^5.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 muhammad-nawlo/multitenant-plugin contains the following files

Loading the files please wait ...