th3mouk / materialized-view-bundle
Symfony bundle for th3mouk/materialized-view: autoconfiguration, console commands, the locked deploy lane, async refresh and read-only ORM guards for PostgreSQL materialized views.
Package info
github.com/Th3Mouk/materialized-view-bundle
Type:symfony-bundle
pkg:composer/th3mouk/materialized-view-bundle
Requires
- php: >=8.4
- doctrine/dbal: ^4.4
- doctrine/doctrine-bundle: ^3.0
- symfony/config: ^8.0
- symfony/console: ^8.0
- symfony/dependency-injection: ^8.0
- symfony/filesystem: ^8.0
- symfony/framework-bundle: ^8.0
- symfony/http-kernel: ^8.0
- th3mouk/materialized-view: ^1.2
Requires (Dev)
- doctrine/doctrine-migrations-bundle: ^4.0
- doctrine/orm: ^3.6
- friendsofphp/php-cs-fixer: ^3.64
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^13.0
- rector/rector: ^2.0
- symfony/error-handler: ^8.0
- symfony/messenger: ^8.0
- symfony/scheduler: ^8.0
Suggests
- doctrine/doctrine-migrations-bundle: For matview:doctrine-lane (drop -> migrate -> sync in one locked process).
- doctrine/orm: For read-only entity mapping and the write/readiness guards.
- symfony/messenger: For PopulationPolicy::Async refresh dispatching.
- symfony/scheduler: To schedule periodic refreshes.
This package is auto-updated.
Last update: 2026-06-09 10:33:04 UTC
README
Symfony integration for
th3mouk/materialized-view— manage PostgreSQL materialized views declaratively, with first-class support for booting the same views across many databases/connections.
The bundle adds, on top of the framework-agnostic core: autoconfiguration of your view definitions, console commands (matview:*), the locked deploy lane (drop --if-pending → migrate → sync in one process), async refresh dispatching, and read-only ORM guards.
Why a separate bundle
The core is intentionally framework-free (DBAL only). Everything Symfony-specific — DI, attributes, commands, Messenger, the Doctrine Migrations lane — lives here so the core can be reused and tested in isolation, and so neither package strands the other on a framework upgrade.
Installation
composer require th3mouk/materialized-view-bundle
Requirements: PHP ≥ 8.4, Symfony ≥ 8.0, Doctrine DBAL ≥ 4.4, DoctrineBundle, PostgreSQL (12+). For the deploy lane, DoctrineMigrationsBundle; for async refresh, Symfony Messenger with a shared transport.
60-second setup (Symfony)
- Register the bundle (Flex usually does this) in
config/bundles.php:
return [ // ... Th3Mouk\MaterializedViewBundle\Th3MoukMaterializedViewBundle::class => ['all' => true], ];
- Declare a view — a
.sqlfile plus an attributed PHP class (auto-discovered, no interface):
use Th3Mouk\MaterializedView\Core\Definition\MaterializedViewDefinition; use Th3Mouk\MaterializedViewBundle\Attribute\AsMaterializedViewProvider; #[AsMaterializedViewProvider] final class SalesByCategoryView { public function definitions(): iterable { yield MaterializedViewDefinition::create('public.sales_by_category') ->fromSql(/* db/matviews/sales_by_category.sql */); } }
- Wire the deploy lane (per database) — see boot lane:
php -d memory_limit=512M bin/console matview:doctrine-lane --no-interaction
Documentation
| Tier | Audience | Start here |
|---|---|---|
| Getting started | Users — wire it into Symfony fast | docs/getting-started.md |
| Guide | Users — commands, config, boot lane, async, templates | docs/guide/ |
| Internals | Maintainers — design & Symfony/Doctrine references | docs/internals/ |
Core concepts (definitions, rebuilds, refresh, locking, hashing, ORM) are documented in the native library docs. This bundle's docs cover the Symfony surface and link back.
Compatibility
| This bundle | PHP | Symfony | DoctrineBundle | Migrations (optional) | Core |
|---|---|---|---|---|---|
^1.0 |
≥ 8.4 | ^8.0 | ^2.13 | ^4.0 | th3mouk/materialized-view:^1.0 |
License
Apache-2.0 — Copyright © 2026 Jérémy Marodon (th3mouk). See NOTICE.
If you use or redistribute this package, keep the NOTICE attribution —
crediting Jérémy Marodon (th3mouk) and naming this library in your product's
documentation or credits. Please contribute upstream rather than
maintaining a public fork.