# patchlevel > Documentation for the patchlevel open-source PHP libraries - a complete event-sourcing toolkit including the core library, framework integrations for Symfony and Laravel, and the hydrator used to (de)serialize events and aggregates. Site: https://patchlevel.dev ## About - patchlevel/event-sourcing is a fully typed, developer-experience focused event-sourcing library for PHP, built on top of the Doctrine ecosystem. - Native integrations exist for Symfony (event-sourcing-bundle) and Laravel (laravel-event-sourcing). - The hydrator package powers (de)serialization of events, aggregates, and value objects. Each link below resolves to the raw markdown source of the page (the same content the on-site renderer consumes), so AI tools can fetch it directly without HTML parsing. For the full markdown of every doc page concatenated into a single file, see https://patchlevel.dev/llms-full.txt. ## patchlevel/event-sourcing > The core PHP event-sourcing library: aggregates, events, repositories, stores, subscriptions, and the message/command/event/query buses. - [Upcasting](https://patchlevel.dev/docs/event-sourcing/latest/upcasting.md) - [Testing](https://patchlevel.dev/docs/event-sourcing/latest/testing.md) - [Our supported versions](https://patchlevel.dev/docs/event-sourcing/latest/supported-versions.md) - [Subscriptions](https://patchlevel.dev/docs/event-sourcing/latest/subscription.md) - [Store](https://patchlevel.dev/docs/event-sourcing/latest/store.md) - [Split Stream](https://patchlevel.dev/docs/event-sourcing/latest/split-stream.md) - [Snapshots](https://patchlevel.dev/docs/event-sourcing/latest/snapshots.md) - [Repository](https://patchlevel.dev/docs/event-sourcing/latest/repository.md) - [Query Bus](https://patchlevel.dev/docs/event-sourcing/latest/query-bus.md) - [Personal Data (GDPR)](https://patchlevel.dev/docs/event-sourcing/latest/personal-data.md) - [Normalizer](https://patchlevel.dev/docs/event-sourcing/latest/normalizer.md) - [Message](https://patchlevel.dev/docs/event-sourcing/latest/message.md) - [Message Decorator](https://patchlevel.dev/docs/event-sourcing/latest/message-decorator.md) - [Getting Started](https://patchlevel.dev/docs/event-sourcing/latest/getting-started.md) - [Events](https://patchlevel.dev/docs/event-sourcing/latest/events.md) - [Event Bus](https://patchlevel.dev/docs/event-sourcing/latest/event-bus.md) - [Command Bus](https://patchlevel.dev/docs/event-sourcing/latest/command-bus.md) - [Clock](https://patchlevel.dev/docs/event-sourcing/latest/clock.md) - [CLI](https://patchlevel.dev/docs/event-sourcing/latest/cli.md) - [Aggregate](https://patchlevel.dev/docs/event-sourcing/latest/aggregate.md) - [Aggregate ID](https://patchlevel.dev/docs/event-sourcing/latest/aggregate-id.md) ## patchlevel/event-sourcing-bundle > Symfony integration for patchlevel/event-sourcing. Autowiring, console commands, Messenger integration, and Flex recipe. - [Usage](https://patchlevel.dev/docs/event-sourcing-bundle/latest/usage.md) - [Installation](https://patchlevel.dev/docs/event-sourcing-bundle/latest/installation.md) - [Event-Sourcing-Bundle](https://patchlevel.dev/docs/event-sourcing-bundle/latest/index.md) - [Getting Started](https://patchlevel.dev/docs/event-sourcing-bundle/latest/getting-started.md) - [Configuration](https://patchlevel.dev/docs/event-sourcing-bundle/latest/configuration.md) ## patchlevel/laravel-event-sourcing > Laravel integration for patchlevel/event-sourcing. Service-provider auto-discovery, Artisan commands and config publishing to wire event sourcing into a Laravel app. - [Installation](https://patchlevel.dev/docs/laravel-event-sourcing/latest/installation.md) - [Laravel Event-Sourcing](https://patchlevel.dev/docs/laravel-event-sourcing/latest/index.md) - [Getting Started](https://patchlevel.dev/docs/laravel-event-sourcing/latest/getting-started.md) - [Facades](https://patchlevel.dev/docs/laravel-event-sourcing/latest/facades.md) - [Configuration](https://patchlevel.dev/docs/laravel-event-sourcing/latest/configuration.md) ## patchlevel/hydrator > The hydration library used in event-sourcing. - [Upcasting](https://patchlevel.dev/docs/hydrator/latest/upcasting.md) - [Normalizer](https://patchlevel.dev/docs/hydrator/latest/normalizer.md) - [Lifecycle Hooks](https://patchlevel.dev/docs/hydrator/latest/lifecycle-hooks.md) - [Lazy Objects](https://patchlevel.dev/docs/hydrator/latest/lazy.md) - [Hydrator](https://patchlevel.dev/docs/hydrator/latest/introduction.md) - [Hydrator](https://patchlevel.dev/docs/hydrator/latest/hydrator.md) - [Guesser](https://patchlevel.dev/docs/hydrator/latest/guesser.md) - [Getting Started](https://patchlevel.dev/docs/hydrator/latest/getting-started.md) - [Extensions](https://patchlevel.dev/docs/hydrator/latest/extensions.md) - [Cryptography](https://patchlevel.dev/docs/hydrator/latest/cryptography.md) - [Caching](https://patchlevel.dev/docs/hydrator/latest/caching.md) ## patchlevel/worker > The worker library used in event-sourcing. - [Worker](https://patchlevel.dev/docs/worker/latest/introduction.md) - [Integration](https://patchlevel.dev/docs/worker/latest/integration.md) - [Getting Started](https://patchlevel.dev/docs/worker/latest/getting-started.md) - [Events & Listeners](https://patchlevel.dev/docs/worker/latest/events.md) ## patchlevel/event-sourcing-phpstan-extension > PHPStan extension for the event-sourcing library. - [event-sourcing-phpstan-extension](https://patchlevel.dev/docs/event-sourcing-phpstan-extension/latest/introduction.md) - [Getting Started](https://patchlevel.dev/docs/event-sourcing-phpstan-extension/latest/getting-started.md) ## patchlevel/event-sourcing-phpunit > PHPUnit extension for the event-sourcing library. - [Testing Subscribers](https://patchlevel.dev/docs/event-sourcing-phpunit/latest/testing-subscribers.md) - [Testing Aggregates](https://patchlevel.dev/docs/event-sourcing-phpunit/latest/testing-aggregates.md) - [Event Sourcing PHPUnit](https://patchlevel.dev/docs/event-sourcing-phpunit/latest/introduction.md) - [Getting Started](https://patchlevel.dev/docs/event-sourcing-phpunit/latest/getting-started.md) ## patchlevel/event-sourcing-analyser > Analyze your event-sourcing domain: See interactions of aggregates, events and subscriptions - [Output](https://patchlevel.dev/docs/event-sourcing-analyser/latest/output.md) - [Event Sourcing Analyser](https://patchlevel.dev/docs/event-sourcing-analyser/latest/introduction.md) - [How It Works](https://patchlevel.dev/docs/event-sourcing-analyser/latest/how-it-works.md) - [Getting Started](https://patchlevel.dev/docs/event-sourcing-analyser/latest/getting-started.md) ## patchlevel/rango > MongoDB API layer for PostgreSQL. - [Update Operators](https://patchlevel.dev/docs/rango/latest/update-operators.md) - [Querying](https://patchlevel.dev/docs/rango/latest/querying.md) - [Rango](https://patchlevel.dev/docs/rango/latest/introduction.md) - [Indexes](https://patchlevel.dev/docs/rango/latest/indexes.md) - [How it Works](https://patchlevel.dev/docs/rango/latest/how-it-works.md) - [Getting Started](https://patchlevel.dev/docs/rango/latest/getting-started.md) - [CRUD Operations](https://patchlevel.dev/docs/rango/latest/crud-operations.md) - [Connection](https://patchlevel.dev/docs/rango/latest/connection.md) - [Aggregation](https://patchlevel.dev/docs/rango/latest/aggregation.md) ## patchlevel/event-sourcing-admin-bundle > Admin dashboard bundle for Symfony. - [Subscriptions](https://patchlevel.dev/docs/event-sourcing-admin-bundle/latest/subscriptions.md) - [Store](https://patchlevel.dev/docs/event-sourcing-admin-bundle/latest/store.md) - [Production Usage](https://patchlevel.dev/docs/event-sourcing-admin-bundle/latest/production-usage.md) - [Introduction](https://patchlevel.dev/docs/event-sourcing-admin-bundle/latest/introduction.md) - [Inspection](https://patchlevel.dev/docs/event-sourcing-admin-bundle/latest/inspection.md) - [Getting Started](https://patchlevel.dev/docs/event-sourcing-admin-bundle/latest/getting-started.md) - [Events](https://patchlevel.dev/docs/event-sourcing-admin-bundle/latest/events.md) ## patchlevel/odm > MongoDB ODM, can be used with Rango but also with MongoDB. - [Repository](https://patchlevel.dev/docs/odm/latest/repository.md) - [Patchlevel ODM](https://patchlevel.dev/docs/odm/latest/introduction.md) - [Getting Started](https://patchlevel.dev/docs/odm/latest/getting-started.md) - [Field Mapping](https://patchlevel.dev/docs/odm/latest/field-mapping.md) - [Encryption](https://patchlevel.dev/docs/odm/latest/encryption.md) - [Documents](https://patchlevel.dev/docs/odm/latest/documents.md) - [Databases](https://patchlevel.dev/docs/odm/latest/databases.md) ## FAQ > Frequently asked questions about the patchlevel event-sourcing libraries, answered inline since they have no dedicated doc pages. - **Is the library free to use?** Yes - and that's our promise: it will never cost anything. The event sourcing library and all integrations are open source under the MIT license, with no paid tiers and no feature gates - not today, not in the future. Every feature you see here, from snapshots to subscriptions, is and stays free. If you want hands-on help, the patchlevel team also offers professional consulting and training. - **What about CQRS?** Event sourcing and CQRS are a natural fit, and the library supports both: aggregates handle your writes, while subscriptions build dedicated read models (projections) optimized for your queries. You can wire in any command bus - like Symfony Messenger - or none at all. CQRS is supported, not forced. - **Do I need a special event store database?** No. The event store runs on the relational database you already operate - PostgreSQL, MariaDB, MySQL, or SQLite - powered by the battle-tested Doctrine DBAL. No extra infrastructure to deploy, back up, or monitor. - **Do I have to event-source my whole application?** No. You can adopt event sourcing per aggregate, exactly where the business value lives - your orders, bookings, or payments - and keep simple CRUD for the rest. The library coexists peacefully with Doctrine ORM, Eloquent, and existing code. - **What happens when my events need to change?** Software evolves, and so do events. Upcasters transform old event payloads on the fly when they are loaded, so you never have to migrate the event store itself. Your history stays immutable while your code moves forward. - **How stable is the library?** Very. We are 100% committed to semantic versioning: no breaking changes within a major version, ever. Deprecations are announced ahead of time and every upgrade path is documented, so updating stays painless. And you are not on your own - we actively maintain the library and provide support on GitHub, with professional support available if you need more. - **What if my framework is not supported?** No problem. The core library is plain PHP with no framework dependency, so it works in any project - Slim, Laminas, CodeIgniter, or no framework at all. If you use Symfony or Laravel, official integrations give you a head start: a Symfony bundle with autowiring, Messenger, and Doctrine migrations, and a Laravel package with auto-discovery and Artisan commands. - **Where do I get help?** Start with the documentation - it covers everything from your first aggregate to advanced topics like snapshots and subscriptions. For questions and bug reports, the team is active on GitHub. And if you need deeper support, patchlevel offers consulting, code reviews, and workshops. ## Blog > Long-form articles on event sourcing, DDD, projections, performance, and PHP design patterns from the Patchlevel team. - [Cutting Your Events the Right Way](https://patchlevel.dev/blog/cutting-your-events-the-right-way.md): One of the first things that trips up newcomers to event sourcing is figuring out how to cut their events. Should it be one big event or many small ones? There is no universal answer, it depends on your domain and on how much the decision you are recording actually changes. In this first part of a two-part series we model the same information in two very different ways and work out when each one is the right call. - [What is New in PHP Event Sourcing 3.20.0](https://patchlevel.dev/blog/what-is-new-in-php-event-sourcing-3-20.md): Version 3.20.0 of patchlevel/event-sourcing focuses on operating event-sourced systems over the long run. You can now keep reading old messages whose header classes were removed, and you can skip the confirmation prompts of the CLI commands to use them in automation. - [What is New in PHP Event Sourcing 3.12 to 3.19](https://patchlevel.dev/blog/what-is-new-in-php-event-sourcing-3-12-to-3-19.md): A lot has happened since our last release post: eight minor releases for patchlevel/event-sourcing. We added an instant retry command bus, subscription cleanup, auto initialized aggregates, PHP 8.5 and Symfony 8 support and much more. Time to catch up on all the highlights from 3.12 to 3.19. - [What is New in PHP Event Sourcing 3.11.0](https://patchlevel.dev/blog/what-is-new-in-php-event-sourcing-3-11.md): Discover what is new in patchlevel/event-sourcing 3.11.0, including improved console commands, a powerful query bus, and gap detection for subscriptions. This release focuses on enhancing developer experience and system resilience with practical, real-world features. - [What is New in PHP Event Sourcing 3.9 & 3.10](https://patchlevel.dev/blog/what-is-new-in-php-event-sourcing-3-9-and-3-10.md): We are excited to announce the release of patchlevel/event-sourcing version 3.9.0 and 3.10.0! These updates introduces features around error handling for the subscription engine and also some nice DX features and PHP 8.4 support. - [What is New in PHP Event Sourcing 3.8](https://patchlevel.dev/blog/what-is-new-in-php-event-sourcing-3-8.md): We are excited to announce the release of patchlevel/event-sourcing version 3.8.0! This update introduces features such as lookup, command bus, read-only event store, and the official release of the stream store. In this post, we will walk you through the key changes. - [The Performance Factor in Event Sourcing: What You Need to Know](https://patchlevel.dev/blog/the-performance-factor-in-event-sourcing.md): This article addresses the common concern regarding the performance of event sourcing, particularly the speed at which long-living aggregates with many events are loaded. It explores solutions such as snapshotting and stream splitting to optimize aggregate loading. Furthermore, projections allow for the creation of highly flexible and optimized read models, each can be tailored to specific needs. - [What is new in patchlevel/event-sourcing in version 3.7](https://patchlevel.dev/blog/what-is-new-in-php-event-sourcing-3-7.md): We’re excited to announce the release of our php library patchlevel/event-sourcing version 3.7.0. This release features better testing capabilities with InMemorySubscriptionStore::clear, improved subscription performance and a new #[Stream] attribute for micro aggregates! - [What is new in php event sourcing 3.6](https://patchlevel.dev/blog/what-is-new-in-php-event-sourcing-3-6.md): We are happy to announce the release of the php event sourcing library in version 3.6.0. This release contains several exciting new features like Pipe and Reducer. In this blog post, we will provide you with an overview of the changes. - [Event Sourcing with Symfony](https://patchlevel.dev/blog/event-sourcing-with-symfony.md): Today we want to show you how to use the event sourcing library with Symfony. We will guide you through the installation, show you how to use the bundle in a small example and give you a working hotel REST-API. - [Mastering sensitive data handling and GDPR compliant secure data removal with event sourcing](https://patchlevel.dev/blog/mastering-sensitive-data-handling-and-gdpr-compliant-secure-data-removal-with-event-sourcing.md): This post explores techniques for handling data removal in event-sourced applications, focusing on compliance and privacy needs, like GDPR. By using methods such as Crypto Shredding and Tokenization for anticipated data deletions, and History Rewriting for unexpected cases, developers can securely remove data while maintaining an immutable event store. - [What is new in php event sourcing 3.5](https://patchlevel.dev/blog/what-is-new-in-php-event-sourcing-3-5.md): We are happy to announce the release of the php event sourcing library in version 3.5.0. This release contains several exciting new features and improvements. In this blog post, we will provide you with an overview of the changes. - [Why should I use event sourcing?](https://patchlevel.dev/blog/why-should-i-use-event-sourcing.md): Today, our topic will be the benefits of event sourcing. We will discuss the possibilities it offers without data loss. The main topics will be reporting & analytics, software architecture & scalability, testing and auditing. - [The good and the bad of event bus in event sourcing](https://patchlevel.dev/blog/the-good-and-the-bad-of-event-bus-in-event-sourcing.md): The event bus is a powerful design pattern in the world of event sourcing. It allows you to decouple the event producers from the event consumers. But it also has its downsides. - [When can I use event sourcing?](https://patchlevel.dev/blog/when-can-i-use-event-sourcing.md): Often, when talking with people about event sourcing and whether they have used it, I get the same answer: "No, I have never used it, but I want to!" My question afterward is always: "So why the hesitation?" Let’s take a look at that. - [What is new in php event sourcing 3.4](https://patchlevel.dev/blog/what-is-new-in-php-event-sourcing-3-4.md): We are happy to announce the release of the php event sourcing library in version 3.4.0. This release contains several exciting new features and improvements. In this blog post, we will provide you with an overview of the changes. - [How to combine ORM entities with event sourcing aggregates](https://patchlevel.dev/blog/combine-orm-with-eventsourcing.md): Inspired by a question on GitHub regarding the combined usage of ORM entities with event sourcing aggregates I decided to write how to do exactly that.