Ecotone
Blog
Documentation
Github
Support and Contact
Search…
Introduction
Installation
Quick Start - DDD CQRS PHP
Tutorial
Modelling
Overview
Command Handling
Query Handling
Event Handling
Interceptors
Saga
Asynchronous Handling
Event Sourcing
Installation and First Steps
Setting up Projections
Persistence
Executing and Managing
Running Projections
Projection CLI Actions
Access Event Store
Emitting events
Projections with State
Document Store
Scheduling
Microservices PHP
Messaging and Ecotone In Depth
Overview
Messaging concepts
Method Invocation And Conversion
Service (Application) Configuration
Registering new Module
Modules
Overview
Symfony Bundle
Laravel
Ecotone Lite
JMS Converter
RabbitMQ Support
DBAL Support
Other
Contact and Support
Prooph Board - Remote Event Storming
Powered By
GitBook
Access Event Store
Use Event Store directly
In some cases you may want to access
Event Store
directly. Event Store is auto registered in your Dependency Container, so you can fetch it like any other service or inject it directly to any Handler.
use
Ecotone
\
EventSourcing
\
EventStore
;
#[
QueryHandler
(
self
::
GET_CURRENT_BALANCE_QUERY
)
]
public
function
getCurrentBalance
(
#[
Reference
]
EventStore
$eventStore
):
array
{
$streamName
=
"wallet"
;
if
(
!
$eventStore
->
hasStream
(
$streamName
))
{
return
[];
}
​
/** @var Event[] $event */
$events
=
$eventStore
->
load
(
$streamName
,
count
:
10
);
​
return
$events
;
}
Previous
Projection CLI Actions
Next
Emitting events
Last modified
1mo ago
Export as PDF
Copy link