An alias “ScnSocialAuth_ZendSessionManager” was requested but no service could be found

只谈情不闲聊 提交于 2019-12-24 12:50:45

问题


I am trying to install ScnSocialAuth_ZendSessionManager into my zend 2 application. i am getting the following error message when i try to go to the login or registration page:

An alias "ScnSocialAuth_ZendSessionManager" was requested but no service could be found.

i have followed the instructions here:

and uploaded it.

i then install

./vendor/socalnick/scn-social-auth/config/scn-social-auth.global.php.dist
/vendor/socalnick/scn-social-auth/config/scn-social-auth.local.php.dist

to my config.

Then within the scn-social-auth.global.php i did the following:

$settings = array(

    'zend_db_adapter' => 'Zend\Db\Adapter\Adapter',

    'zend_session_manager' => 'Zend\Session\SessionManager'
}
);

return array(
    'scn-social-auth' => $settings,
    'service_manager' => array(
        'aliases' => array(
            'ScnSocialAuth_ZendDbAdapter' => (isset($settings['zend_db_adapter'])) ? $settings['zend_db_adapter']: 'Zend\Db\Adapter\Adapter',
            'ScnSocialAuth_ZendSessionManager' => (isset($settings['zend_session_manager'])) ? $settings['zend_session_manager']: 'Zend\Session\SessionManager',
        ),
    ),
);

i also created a ./config/autoload/session.local.php:

<?php

return array(
    'service_manager' => array(
        'invokables' => array(
            'Zend\Session\SessionManager' => 'Zend\Session\SessionManager',
        ),
    ),
); 

so, i am unclear why i am still getting the error message;

would really appriciate any advise on this.

UPDATE

i also added the module to composer:

"require": {
        "php": ">=5.3.3",
        "zendframework/zendframework": "2.*",
        "socalnick/scn-social-auth": "1.*"
    }

UPATE Wilt has asked what values are returned when i var_dump the config values. the returned values are:

  array (size=3)
          'ScnSocialAuth_ZendDbAdapter' => string 'Zend\Db\Adapter\Adapter' (length=23)
          'ScnSocialAuth_ZendSessionManager' => string 'Zend\Session\SessionManager' (length=27)
          'zfcuser_zend_db_adapter' => string 'Zend\Db\Adapter\Adapter' (length=23)

you will observe that the ScnSocialAuth_ZendSessionManager is aliasing the zend sesssion manager.

so, i am unclear why it say that the service cannot be found.

would really appriciate some advice on this.


回答1:


You need the scn-social-auth.global.php and the scn-social-auth.local.php to you application config folder and set all the config parameters that are required.

In this file you find the key 'ScnSocialAuth_ZendSessionManager'. Your issue is probably related to some configuration problem related to these config files.

Since you said you loaded them I would says something is wrong with your autoload setup.

Does your ZF2 application have the proper system configuration:

'module_listener_options' => array(
    'module_paths' => array(
        './module',
        './vendor',
    ),
    'config_glob_paths' => array(
        'config/autoload/{{,*.}global,{,*.}local}.php',
    )
)

Check once if your merged $config array contains all your keys?

$config = $serviceManager->get('Config');


来源:https://stackoverflow.com/questions/33064272/an-alias-scnsocialauth-zendsessionmanager-was-requested-but-no-service-could-b

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!