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

Can't install ecphp/cas-bundle due to Cannot autowire service "Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory" #73

Closed
cctgteddy opened this issue Nov 24, 2022 · 7 comments

Comments

@cctgteddy
Copy link

I'm developing a Symfony 5.4 application

composer require ecphp/cas-bundle loophp/psr-http-message-bridge-bundle

Unfortunately we are stuck on PHP 7.4 at the moment so I can't run the latest version of this bundle which may be fixed. Composer is giving me ecphp/cas-bundle 2.4.2.

"Cannot use ecphp/cas-bundle's latest version 2.5.1 as it requires php >= 8.0.2 which is not satisfied by your platform."

Executing script cache:clear [KO]
 [KO]
Script cache:clear returned with error code 1
!!  
!!  In DefinitionErrorExceptionPass.php line 54:
!!                                                                                 
!!    Cannot autowire service "Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFacto  
!!    ry": argument "$serverRequestFactory" of method "__construct()" references   
!!    interface "Psr\Http\Message\ServerRequestFactoryInterface" but no such serv  
!!    ice exists. Did you create a class that implements this interface?           
!!                                                                                 
!!  
!!  
Script @auto-scripts was called via post-update-cmd

Sorry I know this isn't a lot of info to go on but is there perhaps a missing dependency?

@drupol
Copy link
Member

drupol commented Nov 24, 2022

Hi !

Try to add nyholm/psr7 and it should be fixed.

Let me know how it goes.

@drupol
Copy link
Member

drupol commented Nov 25, 2022

Hi again,

Can you share your composer.json file so I can try to reproduce the issue locally ?

Thanks!

@cctgteddy
Copy link
Author

Adding nyholm/psr7 let me install it, but I'm struggling to make auth work.

Here's my composer.json.

The one package "ctg/cctg-bundle" is from a private repository which has these items. We are running PHP 7.4.30

  "require": {  
    "symfony/framework-bundle": "^5.4||^6.0",
    "doctrine/dbal": "^3",
    "apereo/phpcas": "1.5.*"
  }
{
    "type": "project",
    "license": "proprietary",
    "minimum-stability": "stable",
    "prefer-stable": true,
    "require": {
        "php": ">=7.2.5",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "ctg/cctg-bundle": "dev-master",
        "doctrine/annotations": "^1.0",
        "doctrine/doctrine-bundle": "^2.7",
        "doctrine/orm": "^2.13",
        "ecphp/cas-bundle": "^2.4",
        "friendsofsymfony/jsrouting-bundle": "^2.8",
        "knplabs/knp-markdown-bundle": "^1.10",
        "league/commonmark": "^2.3",
        "nyholm/psr7": "^1.5",
        "phpdocumentor/reflection-docblock": "^5.3",
        "phpstan/phpdoc-parser": "^1.8",
        "sensio/framework-extra-bundle": "^6.1",
        "symfony/apache-pack": "^1.0",
        "symfony/asset": "5.4.*",
        "symfony/console": "5.4.*",
        "symfony/dotenv": "5.4.*",
        "symfony/expression-language": "5.4.*",
        "symfony/flex": "^1.17|^2",
        "symfony/form": "5.4.*",
        "symfony/framework-bundle": "5.4.*",
        "symfony/http-client": "5.4.*",
        "symfony/intl": "5.4.*",
        "symfony/mailer": "5.4.*",
        "symfony/mime": "5.4.*",
        "symfony/monolog-bundle": "^3.0",
        "symfony/property-access": "5.4.*",
        "symfony/property-info": "5.4.*",
        "symfony/runtime": "5.4.*",
        "symfony/security-bundle": "5.4.*",
        "symfony/serializer": "5.4.*",
        "symfony/string": "5.4.*",
        "symfony/translation": "5.4.*",
        "symfony/twig-bundle": "5.4.*",
        "symfony/validator": "5.4.*",
        "symfony/web-link": "5.4.*",
        "symfony/yaml": "5.4.*",
        "twig/extra-bundle": "^3.4",
        "twig/markdown-extra": "^3.4",
        "twig/twig": "^2.12|^3.0"
    },
    "config": {
        "allow-plugins": {
            "composer/package-versions-deprecated": true,
            "symfony/flex": true,
            "symfony/runtime": true
        },
        "optimize-autoloader": true,
        "preferred-install": {
            "*": "dist"
        },
        "sort-packages": true
    },
    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "App\\Tests\\": "tests/"
        }
    },
    "replace": {
        "symfony/polyfill-ctype": "*",
        "symfony/polyfill-iconv": "*",
        "symfony/polyfill-php72": "*"
    },
    "scripts": {
        "auto-scripts": {
            "cache:clear": "symfony-cmd",
            "assets:install %PUBLIC_DIR%": "symfony-cmd"
        },
        "post-install-cmd": [
            "@auto-scripts"
        ],
        "post-update-cmd": [
            "@auto-scripts"
        ]
    },
    "conflict": {
        "symfony/symfony": "*"
    },
    "extra": {
        "symfony": {
            "allow-contrib": false,
            "require": "5.4.*"
        }
    },
    "require-dev": {
        "doctrine/doctrine-fixtures-bundle": "^3.4",
        "phpunit/phpunit": "^9.5",
        "symfony/browser-kit": "5.4.*",
        "symfony/css-selector": "5.4.*",
        "symfony/debug-bundle": "5.4.*",
        "symfony/maker-bundle": "^1.0",
        "symfony/phpunit-bridge": "^6.1",
        "symfony/stopwatch": "5.4.*",
        "symfony/web-profiler-bundle": "5.4.*"
    },
    "repositories": [
        {
            "type": "composer",
            "url": "https://magneto.ctg.queensu.ca/composer"
        }
    ]
}

also my security.yaml

security:
    enable_authenticator_manager: true
    # https://symfony.com/doc/current/security.html#loading-the-user-the-user-provider
    #providers:
    #    cctg:
    #        id: cctg.user_provider
    firewalls:
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false
        main:
            switch_user: true
            lazy: true
     #       provider: cctg
            custom_authenticators:
                # - cctg_bundle.cas_auth
                - cas.authenticator

    access_control:
        - { path: ^/admin, roles: ROLE_ADMIN }
        - { path: ^/, roles: ROLE_CAS_AUTHENTICATED }

@drupol
Copy link
Member

drupol commented Nov 25, 2022

Adding nyholm/psr7 let me install it, but I'm struggling to make auth work.

Can you describe what's wrong?

@drupol
Copy link
Member

drupol commented Nov 29, 2022

Hello @cctgteddy ,

Can you let me know if the issue is still relevant?

Thanks.

@cctgteddy
Copy link
Author

Oops, sorry. Appreciate your help. I never did figure out what was wrong, it just wasn't authenticating. No error messages or anything. I may come back to this, but I managed to get this working using my own Authenticator which just wrapped around phpCAS instead.

@drupol
Copy link
Member

drupol commented Nov 29, 2022

That's sad. I would not recommend to use PHPCas within a Symfony app.

I could give some better assistance if I would have at least an error message... but ok.

Feel free to come back to us if you change your mind.

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

2 participants