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

make:migration fails with default setup #205

Closed
Crell opened this issue Jan 19, 2022 · 5 comments
Closed

make:migration fails with default setup #205

Crell opened this issue Jan 19, 2022 · 5 comments

Comments

@Crell
Copy link

Crell commented Jan 19, 2022

I am following through the recommended setup from the README, but running into issues. Specifically:

bin/console make:reset-password

Walks through the wizard just fine, no error. At the end, it says to run bin/console make:migration

However, doing so results in this error:

 Cannot autowire service "App\Controller\ResetPasswordController": argument "$resetPasswordHelper" of method "__construct()" references interface "SymfonyCasts\Bundle\ResetPassword\ResetPasswordHelperInterface" but no such service exists. Did you create a class that implements this interface? 

Which suggests that the services are not being autowired correctly. I added the following to services.yaml:

    SymfonyCasts\Bundle\ResetPassword\:
        resource: '../vendor/symfonycasts/reset-password-bundle/src'

Then running make:migration again results in:

Cannot autowire service "SymfonyCasts\Bundle\ResetPassword\ResetPasswordHelperInterface": argument "$generator" of method "SymfonyCasts\Bundle\ResetPassword\ResetPasswordHelper::__construct()" references class "SymfonyCasts\Bundle\ResetPassword\Generator\ResetPasswordTokenGenerator" but no such service exists.    

Yet that class does indeed exist.

At this point I figure there's something more wrong, so I put out a call for help. :-)

Running Symfony 5.4 on PHP 8.1.

@Sebbaz
Copy link

Sebbaz commented Jan 22, 2022

Hello,

Same result with Symfony 4.4

Interestingly, there is a warning message about the command make:reset-password does'nt find config/packages/reset_password.yaml file that does not exists.

 created: src/Controller/ResetPasswordController.php
 created: src/Entity/ResetPasswordRequest.php
 updated: src/Entity/ResetPasswordRequest.php
 created: src/Repository/ResetPasswordRequestRepository.php
 updated: src/Repository/ResetPasswordRequestRepository.php
 We can't find config/packages/reset_password.yaml. That's ok, you probably have a customized configuration.
 Just remember to set the request_password_repository in your configuration.

 created: src/Form/ResetPasswordRequestFormType.php
 created: src/Form/ChangePasswordFormType.php
 created: templates/reset_password/check_email.html.twig
 created: templates/reset_password/email.html.twig
 created: templates/reset_password/request.html.twig
 created: templates/reset_password/reset.html.twig

           
  Success! 
           

 Next:
   1) Run "php bin/console make:migration" to generate a migration for the new "App\Entity\ResetPasswordRequest" entity.
   2) Review forms in "src/Form" to customize validation and labels.
   3) Review and customize the templates in `templates/reset_password`.
   4) Make sure your MAILER_DSN env var has the correct settings.
   5) Create a "forgot your password link" to the app_forgot_password_request route on your login form.

 Then open your browser, go to "/reset-password" and enjoy!

then

php7 bin/console make:migration

In DefinitionErrorExceptionPass.php line 54:
                                                                                                                                                                                                                                       
  Cannot autowire service "App\Controller\ResetPasswordController": argument "$resetPasswordHelper" of method "__construct()" references interface "SymfonyCasts\Bundle\ResetPassword\ResetPasswordHelperInterface" but no such servi  
  ce exists. Did you create a class that implements this interface?

Forced autowire :

php7 bin/console make:migration

In DefinitionErrorExceptionPass.php line 54:
                                                                                                                                                                                                                                       
  Cannot autowire service "SymfonyCasts\Bundle\ResetPassword\ResetPasswordHelper": argument "$repository" of method "__construct()" references interface "SymfonyCasts\Bundle\ResetPassword\Persistence\ResetPasswordRequestRepositor  
  yInterface" but no such service exists. You should maybe alias this interface to one of these existing services: "App\Repository\ResetPasswordRequestRepository", "SymfonyCasts\Bundle\ResetPassword\Persistence\Fake\FakeResetPass  
  wordInternalRepository".                                                                                                                                                                                                             
 

When trying to add the config, the symfonycasts_reset_password namespace is not available for yaml config

  There is no extension able to load the configuration for "symfonycasts_reset_password" (in "***/config/packages/reset_password.yaml"). Looked for namespace "symfonycasts_reset_password", found ""frame  
  work", "security", "twig", "twig_extra", "sensio_framework_extra", "doctrine", "doctrine_migrations", "web_profiler", "monolog", "debug", "maker", "web_server", "doctrine_fixtures", "swiftmailer"".                                
 

@Sebbaz
Copy link

Sebbaz commented Jan 22, 2022

I solved it

At this point I figure there's something more wrong, so I put out a call for help. :-)

May the issue #133 helps you, I found a problem in composer installation of plugin symfony/flex.

After check the project structure with official doc https://symfony.com/doc/current/setup/flex.html

Run php7 /usr/bin/composer show symfony/flex to check flex version ^1.6

And run composer recipes:install symfonycasts/reset-password-bundle --force -v as described here #133 (comment)

It successfully created file config/packages/reset_password.yaml

and at this point, php bin/console make:migration works fine.

@Crell
Copy link
Author

Crell commented Jan 24, 2022

Hm. Running the recipes:install command runs, but then I get this error from the cache:clear step:

  In CheckExceptionOnInvalidReferenceBehaviorPass.php line 86:
!!                                                                                 
!!    The service "symfonycasts.reset_password.cleaner" has a dependency on a non  
!!    -existent service "App\Repository\PasswordResetRequestRepository". Did you   
!!    mean this: "App\Repository\ResetPasswordRequestRepository"?  

I may try the whole thing over from scratch in a new branch shortly. :-(

@jrushlow
Copy link
Collaborator

Howdy @Crell - sounds like the reset password config is missing.. do you have a

# config/packages/reset_password.yaml

symfonycasts_reset_password:
    request_password_repository: App\Repository\ResetPasswordRequestRepository

@Crell
Copy link
Author

Crell commented Feb 9, 2022

That file wasn't created originally; and when I created it by hand before it didn't do anything.

However, I then started over from scratch with a new branch, and that file was created by the setup script.

I do not know why it was different, but that did resolve that issue. So, I guess I can close this. Thanks.

@Crell Crell closed this as completed Feb 9, 2022
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