Download the PHP package laymont/postgres-multi-tenant without Composer

On this page you can find all versions of the php package laymont/postgres-multi-tenant. 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 postgres-multi-tenant

laymont/postgres-multi-tenant

Este paquete proporciona una base para implementar multi-tenancy schema-per-tenant en PostgreSQL para proyectos Laravel 12/13, con foco en buenas prácticas, tipado estricto y testabilidad.

Objetivo

Enfoque

Este paquete implementa el patrón probado en producción para Postgres schema-per-tenant:

Garantías anti-fuga (lo más importante)

Config:

Resolución de Tenant (baja fricción)

Por defecto, el paquete resuelve el schema desde el header:

Puedes cambiarlo definiendo postgres-multi-tenant.tenant_resolver con una clase que implemente Laymont\PostgresMultiTenant\Contracts\TenantResolver.

Resolvers incluidos:

Middleware recomendado

Middleware incluido:

Config clave:

Jobs (Laravel Queue)

Este paquete se apega al marco de Laravel:

Para eso se incluye un Job Middleware compatible con Laravel:

Y un contrato para jobs tenant-aware:

Migraciones (Laravel Migrations)

Este paquete también se apega al marco de Laravel:

Comando incluido:

Compatibilidad

Instalación

Implementación (proyecto nuevo)

1) Publica la configuración

2) Configura el comportamiento del paquete

Edita config/postgres-multi-tenant.php.

Recomendado (anti-fuga por defecto):

Nota: el paquete prioriza config() (cache-safe). En producción debes usar php artisan config:cache como en cualquier app Laravel.

3) Decide cómo resolver el tenant

Opción recomendada (API):

Si necesitas otra estrategia, define tenant_resolver con una clase que implemente:

4) Registra el middleware

El middleware incluido es:

Ejemplo (Laravel 12/13): agrega el middleware donde tu aplicación registre middleware (por ejemplo, a nivel de rutas o grupo de rutas).

Recomendación:

5) Define el contrato de “schema name”

Recomendación: usa un patrón de schemas consistente (por ejemplo tenant_acme) y mantén el regex en:

Esto es una protección contra esquemas inválidos y reduce vectores de fuga.

Implementación (proyecto existente)

1) Asegura tu conexión pgsql

Verifica que tu config/database.php (o la configuración equivalente) use PostgreSQL y que la conexión que vaya a operar en modo tenant sea la misma que definiste en:

2) Evita fugas por workers persistentes

Si usas Octane o workers persistentes:

3) Adopta gradualmente

Puedes empezar aplicando el middleware solo a un subset de endpoints tenant-aware.

Jobs (Laravel Queue) - implementación

Principio: cola global (tabla jobs en public) + ejecución tenant-aware.

Para que un job sea tenant-aware, implementa:

Y agrega el middleware al job:

El middleware asegura:

Migraciones - implementación

Para migrar un schema tenant:

Esto ejecuta migrate de Laravel dentro del contexto del tenant, permitiendo que Laravel cree y use:

Verificación rápida (debug)

En Postgres puedes verificar el schema actual con:

En runtime, el guardrail del paquete compara current_schema() contra el schema esperado cuando está habilitado.

Configuración

Publicar configuración:

Esto creará config/postgres-multi-tenant.php.

Uso

Ver secciones:

Licencia

MIT.


All versions of postgres-multi-tenant with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/support Version ^12.0|^13.0
illuminate/database Version ^12.0|^13.0
illuminate/http Version ^12.0|^13.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 laymont/postgres-multi-tenant contains the following files

Loading the files please wait ...