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

Error in token controller #42

Closed
asalisaf opened this issue Apr 16, 2019 · 19 comments
Closed

Error in token controller #42

asalisaf opened this issue Apr 16, 2019 · 19 comments
Labels
question Further information is requested

Comments

@asalisaf
Copy link

Hey
I got this error on calling token route:

Cannot autowire argument $serverRequest of "trikoder.oauth2.controller.token_controller:indexAction()": it references interface "Psr\Http\Message\ServerRequestInterface" but no such service exists. Did you create a class that implements this interface?

@rsuper
Copy link

rsuper commented Apr 19, 2019

I had this too. I fixed it by creating these services:

    Symfony\Bridge\PsrHttpMessage\Factory\DiactorosFactory: ~

    Psr\Http\Message\ServerRequestInterface:
        factory: 'Symfony\Bridge\PsrHttpMessage\Factory\DiactorosFactory:createRequest'
        arguments: ['@=service("request_stack").getMasterRequest()']

@unlikenesses
Copy link

I am also getting this error. Perhaps it's due to a recent update in Symfony, because it was working a week ago.

@spideyfusion
Copy link
Contributor

We are working on this in #43. The plan is to have it merged by tomorrow.

@unlikenesses
Copy link

Can confirm that it now works without needing to add the services in this answer.

@developer-ruben
Copy link

developer-ruben commented Apr 24, 2019

After the update from today and installing the nyholm/psr7 package I'm getting this error:

The service alias "Psr\Http\Message\ServerRequestFactoryInterface" does not exist.

@spideyfusion
Copy link
Contributor

spideyfusion commented Apr 24, 2019

@rubenodeman SensioFrameworkExtraBundle should setup the default autowiring aliases for you. Have you tried clearing your entire var/cache folder?

If you're still getting the error, post the entire stack trace of the error please.

Make sure you're targeting dev-master until we tag a new release.

@developer-ruben
Copy link

developer-ruben commented Apr 24, 2019

Thanks for the quick reply! Still getting the error after clearing the cache.

(1/1) InvalidArgumentExceptionThe service alias "Psr\Http\Message\ServerRequestFactoryInterface" does not exist.

in ContainerBuilder.php line 899
at ContainerBuilder->getAlias('Psr\Http\Message\ServerRequestFactoryInterface')in TrikoderOAuth2Extension.php line 90
at TrikoderOAuth2Extension->assertPsrHttpAliasesExist(object(ContainerBuilder))in TrikoderOAuth2Extension.php line 75
at TrikoderOAuth2Extension->process(object(ContainerBuilder))in ExtensionCompilerPass.php line 34
at ExtensionCompilerPass->process(object(ContainerBuilder))in Compiler.php line 95
at Compiler->compile(object(ContainerBuilder))in ContainerBuilder.php line 750
at ContainerBuilder->compile()in Kernel.php line 544
at Kernel->initializeContainer()in Kernel.php line 133
at Kernel->boot()in Kernel.php line 193
at Kernel->handle(object(Request))in index.php line 25

@spideyfusion
Copy link
Contributor

spideyfusion commented Apr 24, 2019

@rubenodeman Make sure you have SensioFrameworkExtraBundle enabled in your kernel:

Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true]

@developer-ruben
Copy link

Solved! Thanks for the support!

@spideyfusion
Copy link
Contributor

@rubenodeman No problem. I'll add a check in a compiler pass to alert the developer if the required bundles are not enabled so other folks don't run into the same situation. :)

@rbaarsma
Copy link

rbaarsma commented Jun 4, 2019

I have this issue after upgrading from sensio/framework-bundle 5.2.4 to 5.3.1. I've tried clearing the cache manually (rm -rf var/cache) and have checked that sensioFrameworkExtraBundle is indeed enabled.

@rbaarsma
Copy link

rbaarsma commented Jun 4, 2019

Opened an issue on sensio/framework-extra-bundle: https://github.com/sensiolabs/SensioFrameworkExtraBundle/issues/620

@rbaarsma
Copy link

rbaarsma commented Jun 4, 2019

I just tried to update trikoder/oauth2-bundle to the dev-master version (with the sensio/framework-extra-bundle at 5.3.1), but that doesn't want to install

  Problem 1
    - Can only install one of: symfony/psr-http-message-bridge[v1.2.0, v1.0.2].
    - Can only install one of: symfony/psr-http-message-bridge[v1.2.0, v1.0.2].
    - Can only install one of: symfony/psr-http-message-bridge[v1.2.0, v1.0.2].
    - trikoder/oauth2-bundle dev-master requires symfony/psr-http-message-bridge ^1.2 -> satisfiable by symfony/psr-http-message-bridge[v1.2.0].
    - Installation request for trikoder/oauth2-bundle dev-master -> satisfiable by trikoder/oauth2-bundle[dev-master].
    - Installation request for symfony/psr-http-message-bridge (locked at v1.0.2) -> satisfiable by symfony/psr-http-message-bridge[v1.0.2].

Note: I'm using symfony 4.2 (not 4.3)..
And I don't have nyholm/psr7 installed, as it isn't a requirement for anything as far as I can tell.. they even removed it as a requirement in sensio/framework-extra-bundle 5.3.0

@spideyfusion
Copy link
Contributor

spideyfusion commented Jun 4, 2019

@rbaarsma What version of symfony/psr-http-message-bridge are you targeting in your composer.json file? It should be at least 1.2.

@rbaarsma
Copy link

rbaarsma commented Jun 4, 2019

Not targeting any version. Shouldn't that requirement be automatically upgraded when your requirements are to have it at ^1.2. It's not like I'm limiting that version somehow?

@X-Coder264
Copy link
Collaborator

@rbaarsma Try composer update trikoder/oauth2-bundle --with-dependencies.

@rbaarsma
Copy link

rbaarsma commented Jun 4, 2019

Okay so eventually I did the following:

bash$ composer require nyholm/psr7
# changed composer.json manually to use "dev-master " as a value for trikoder/oauth2-bundle and "^1.2" for "symfony/psr-http-message-bridge"
bash$ composer update trikoder/oauth2-bundle symfony/psr-http-message-bridge

Note that it didn't work to just update trikoder-oauth2-bundle to dev-master.

This fixes my issue. I hope this version gets tagged soon ;)

@X-Coder264
Copy link
Collaborator

Of course just updating trikoder-oauth2-bundle to dev-master didn't fix the issue. It was documented in #43 that nyholm/psr7 should be manually required too.

I'm glad that we finally fixed the issue.

@X-Coder264
Copy link
Collaborator

v2.0.0-beta1 was tagged and 2.0 will be tagged soon too so I'm closing this issue.

@spideyfusion spideyfusion added the question Further information is requested label Aug 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

7 participants