[GH-ISSUE #1959] Class not find for DateTimeImmutable in Logger #841

Closed
opened 2026-03-04 03:01:19 +03:00 by kerem · 2 comments
Owner

Originally created by @titospeakap on GitHub (Mar 24, 2025).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/1959

Monolog version 2

In the class Logger, in version 2, line 383, we have

'datetime' => $datetime ?? new DateTimeImmutable($this->microsecondTimestamps, $this->timezone),

but class DateTimeImmutable was not imported. We need to add a use statement or use \DateTimeImmutable.

Right now, in our project, we are getting the error

PHP Warning:  include(/opt/speakap/versions/releases/20250317180438/vendor/composer/../monolog/monolog/src/Monolog/DateTimeImmutable.php): Failed to open stream: No such file or directory
Originally created by @titospeakap on GitHub (Mar 24, 2025). Original GitHub issue: https://github.com/Seldaek/monolog/issues/1959 Monolog version 2 In the class Logger, in version 2, line 383, we have ``` 'datetime' => $datetime ?? new DateTimeImmutable($this->microsecondTimestamps, $this->timezone), ``` but class `DateTimeImmutable` was not imported. We need to add a use statement or use `\DateTimeImmutable`. Right now, in our project, we are getting the error ``` PHP Warning: include(/opt/speakap/versions/releases/20250317180438/vendor/composer/../monolog/monolog/src/Monolog/DateTimeImmutable.php): Failed to open stream: No such file or directory ```
kerem 2026-03-04 03:01:19 +03:00
  • closed this issue
  • added the
    Bug
    label
Author
Owner

@stof commented on GitHub (Mar 24, 2025):

the file src/Monolog/DateTimeImmutable.php definitely exists in Monolog 2.x: https://github.com/Seldaek/monolog/blob/2.x/src/Monolog/DateTimeImmutable.php

So make sure you are not deleting files from your vendor folder.

<!-- gh-comment-id:2748001227 --> @stof commented on GitHub (Mar 24, 2025): the file `src/Monolog/DateTimeImmutable.php` definitely exists in Monolog 2.x: https://github.com/Seldaek/monolog/blob/2.x/src/Monolog/DateTimeImmutable.php So make sure you are not deleting files from your `vendor` folder.
Author
Owner

@titospeakap commented on GitHub (Mar 24, 2025):

sorry @stof , my bad... indeed the file exists, something else going on.. I'll close the ticket. Thanks for the quick reply.

<!-- gh-comment-id:2748043959 --> @titospeakap commented on GitHub (Mar 24, 2025): sorry @stof , my bad... indeed the file exists, something else going on.. I'll close the ticket. Thanks for the quick reply.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/monolog#841
No description provided.