event-store-http-client icon indicating copy to clipboard operation
event-store-http-client copied to clipboard

Could not create DateTimeImmutable from string while getting stream events

Open bogdandubyk opened this issue 4 years ago • 4 comments

When I'm trying to get events from stream, I'm getting the error Could not create DateTimeImmutable from string "2020-12-13T23:00:57.1574786Z". where 2020-12-13T23:00:57.1574786Z is the string representation of date in updated field

Here is a sample snippet code :

        $connection = EventStoreConnectionFactory::create(
            new ConnectionSettings(
                new EndPoint('localhost', 2113),
                'http',
            ),
            $this->httpClient,
            null
        );
        $connection->appendToStream(
             'newstream',
             ExpectedVersion::ANY,
             [
                 new EventData(
                     EventId::generate(),
                     'test-type',
                     true,
                     json_encode(['a' => '2']),
                     'meta'
                 )
             ]
         ));

        return $connection->readStreamEventsForward('newstream',0, 100));

and it's failing in Prooph\EventStoreHttpClient\Internal\ResolvedEventParser line 87, when creating RecordedEvent object.

I'm new to this package and to eventstore DB in general, so sorry if a question is stupid and issue is on my side, but I do not see how it can be on my side, as I do not rpovide any datetes while saving event, so I'm assuming issues is on package or eventstore configuration

bogdandubyk avatar Dec 14 '20 08:12 bogdandubyk

Can you try with dev-master? There were some fixes around date formats.

enumag avatar Dec 14 '20 08:12 enumag

yeah, it's working now, one more question, is ti package can be used in production? I'm looking for some ready to production solution, but it seems that no other solution for PHP?

bogdandubyk avatar Dec 14 '20 13:12 bogdandubyk

@prolic ?

enumag avatar Dec 14 '20 18:12 enumag

dev-master branch should be good to be used in production. I'm planning to release 1.0 final soon, but need to finish the documentation first and I am super busy right now.

prolic avatar Dec 14 '20 21:12 prolic