The class ‘DateTime’ was not found in the chain configured namespaces AppEntity

After a "composer update" on my Symfony porject, I have this error inside my repository:

class UserRepository extends ServiceEntityRepository implements PasswordUpgraderInterface
    public function __construct(ManagerRegistry $registry)
        parent::__construct($registry, User::class);

    public function countOnlineUsers(): int
        return $this->createQueryBuilder('u')
            ->select('count(u) as userOnline')
            ->where('u.lastSeenDate >= :time')
            ->setParameter('time', (new DateTime())->modify('-15 minutes'))

I use new DateTime() on different place of the project and I don’t have this error on other place.

enter image description here

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *