Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Unresolvable dependency resolving [Parameter #0 [ <required> $entityName ]] in class Doctrine\ORM\Mapping\ClassMetadata #540

Open
RobQuistNL opened this issue Jan 31, 2023 · 3 comments

Comments

@RobQuistNL
Copy link

RobQuistNL commented Jan 31, 2023

Package version, Laravel version

Lumen v8.3.4

Expected behaviour

The ClassMetadata class gets instantiated properly

Actual behaviour

It looks like the DI tries to fill $entityName in this constructor;
https://github.com/doctrine/orm/blob/2.14.x/lib/Doctrine/ORM/Mapping/ClassMetadata.php#L24-L27

Steps to reproduce the behaviour

Install Lumen
Follow the steps defined here; http://www.laraveldoctrine.org/docs/1.8/orm/lumen

@eigan
Copy link
Member

eigan commented Feb 1, 2023

It would be helpful to see the entire stacktrace

@dpslwk
Copy link
Member

dpslwk commented Feb 1, 2023

Lumen is no longer recommended for new project

@RobQuistNL
Copy link
Author

RobQuistNL commented Feb 1, 2023

I know Lumen is not recommended (heck, I'd not even recommend laravel), but we had to work with it.

I managed to initially fix it by manually binding all repository classes as a singleton, but that was messy - eventually simply installing doctrine/doctrine-bundle solved the issue.

My repositories now no longer extend Doctrine\ORM\EntityRepository but the Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository from the bundle, and then we have a simple constructor in the repository;

use App\Models\User;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
use Illuminate\Pagination\LengthAwarePaginator;
use LaravelDoctrine\ORM\Pagination\PaginatesFromParams;

class UserRepository extends ServiceEntityRepository
{
    use PaginatesFromParams;

    public function __construct(ManagerRegistry $registry)
    {
        parent::__construct($registry, User::class);
    }
//...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants