markitosgv/JWTRefreshTokenBundle

Package installation breaks User Entity in SF 6

papsko opened this issue · 5 comments

Hello,

I'm trying to use the package with Symfony 6.1, PHP 8.1.
As first thing I installed and tested Lexik JWT Bundle and created User entity with make:user command. Everything was ok. I was able to create user and get the jwt via login. Afterwards I installed JWTRefreshTokenBundle and configured it according to documentation. After updating database schema to create "refresh_token" table it turned out that my "user" table has been droped (even though entity code remained unchaged) and after trying to call "make:entity" on User I get following error:

Cannot find the entity manager for class "App\Entity\User"

EDIT:

I checked and same thing happens on Symfony 6.0 too.

To reproduce - with php8.1:

symfony new project-name --version="6.0.*"
cd project-name
composer rquire api
composer reqire maker-bundle
php bin/console make:user #create user with default settings
composer require "lexik/jwt-authentication-bundle"

Up to this moment everything works good. You can still edit User entity using php bin/console make:entity
Now:

composer require gesdinet/jwt-refresh-token-bundle #and execute recipe

Since now calling php bin/console make:entity on User gives "Cannot find entity manager for class App\Entity\User".
Same error pops up when I try to use entity manager for User anywhere in the code.

Removing the package with composer remove gesdinet/jwt-refresh-token-bundle makes User entity work again.

Did anyone else bumped into this issue or am I missing something obvious?

I'm having the same issue.

In case someone is intrested I managed to overcome this issue by installing jwt-refresh-token-bundle first and then creating User entity. Moreover I commited this freshly created project, cloned it to different location and installed it with composer install - this way it also works normally.

It seems that only composer require gesdinet/jwt-refresh-token-bundle produces this issue.

I also have this problem on LTS.

Found a solution:

  1. Change the Annotations to Attributes in the generated "RefreshToken.php"
  2. Make sure that doctrine ORM is configured to use Attributes (see https://stackoverflow.com/a/70698782)

@Luehrsen
thx, this solved the issue

<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Gesdinet\JWTRefreshTokenBundle\Entity\RefreshToken as BaseRefreshToken;
#[
    ORM\Entity,
    ORM\Table('refresh_tokens'),
]
class RefreshToken extends BaseRefreshToken
{
}