Download the PHP package macpaw/postgres-schema-bundle without Composer
On this page you can find all versions of the php package macpaw/postgres-schema-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download macpaw/postgres-schema-bundle
More information about macpaw/postgres-schema-bundle
Files in macpaw/postgres-schema-bundle
Package postgres-schema-bundle
Short Description A Symfony bundle to add schema wrapper for postgres
License MIT
Informations about the package postgres-schema-bundle
Postgres Schema Bundle
The Postgres Schema Bundle provides seamless multi-tenant schema support for PostgreSQL within Symfony applications. It automatically switches PostgreSQL search_path based on the current request context and ensures proper schema resolution across Doctrine and Messenger.## Installation
Features
- Automatically sets PostgreSQL
search_pathfrom request headers. - Validates that the schema exists in the database.
- Works only if the configured database driver is PostgreSQL.
- Integrates with Schema Context Bundle.
- Compatible with Symfony Messenger and Doctrine ORM.
Installation
Use Composer to install the bundle:
Applications that don't use Symfony Flex
Enable the bundle by adding it to the list of registered bundles in
Configuration
You must tell Doctrine to use the SchemaConnection class as its DBAL connection class:
Set BaggageSchemaResolver to SchemaConnection at kernel boot
Make sure you configure the context bundle properly:
See https://github.com/MacPaw/schema-context-bundle/blob/develop/README.md
How it Works
- A request comes in with a header like X-Tenant-Id: tenant123.
- The SchemaRequestListener sets this schema in the context.
- When Doctrine connects to PostgreSQL, it sets the search_path to the specified schema.
- If the schema does not exist or DB is not PostgreSQL, an exception is thrown.
Optional Commands
The bundle provides three optional commands for schema management that can be registered in your services configuration:
Schema Drop Command
Drops a PostgreSQL schema and all its objects:
Usage:
Schema Migrations Command
Runs Doctrine migrations within a specific schema. Creates the schema if it doesn't exist:
Usage:
Schema Fixtures Load Command
Loads Doctrine fixtures within a specific schema:
Usage:
Note: These commands are optional and should only be registered if you're using the corresponding Doctrine features (migrations and/or fixtures) in your project.
Testing
To run tests:
Contributing
Feel free to open issues and submit pull requests.
License
This bundle is released under the MIT license.
All versions of postgres-schema-bundle with dependencies
doctrine/orm Version ^2.17 || ^3.0
symfony/doctrine-bridge Version ^6.4 || ^7.0
doctrine/dbal Version ^3.4
macpaw/schema-context-bundle Version ^2.0.4