Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/258.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Silex定制认证带防护装置_Php_Security_Token_Silex_Guard - Fatal编程技术网

Php Silex定制认证带防护装置

Php Silex定制认证带防护装置,php,security,token,silex,guard,Php,Security,Token,Silex,Guard,我尝试按照上的教程进行操作,但在将身份验证程序注册为服务时出错 Catchable致命错误:传递给App\Security\TokenAuthenticator::\uu construct()的参数1必须是App\Security\EncoderFactoryInterface的实例,给定的Symfony\Component\Security\Core\Encoder\EncoderFactory的实例,在第41行的C:\wamp\www\api\src\app.php中调用,并在第17行的C

我尝试按照上的教程进行操作,但在将身份验证程序注册为服务时出错

Catchable致命错误:传递给App\Security\TokenAuthenticator::\uu construct()的参数1必须是App\Security\EncoderFactoryInterface的实例,给定的Symfony\Component\Security\Core\Encoder\EncoderFactory的实例,在第41行的C:\wamp\www\api\src\app.php中调用,并在第17行的C:\wamp\www\api\src\app\Security\TokenAuthenticator.php中定义

这是我的app.php

$app = new Silex\Application(['debug' => true]);

$app['security.firewalls'] = array(
    'main' => array(
        'guard' => array(
            'authenticators' => array(
                'app.token_authenticator'
            ),

            // Using more than 1 authenticator, you must specify
            // which one is used as entry point.
            // 'entry_point' => 'app.token_authenticator',
        ),
        // configure where your users come from. Hardcode them, or load them from somewhere
        // http://silex.sensiolabs.org/doc/providers/security.html#defining-a-custom-user-provider
        'users' => array(
        //raw password = foo
            'test' => array('ROLE_USER', '$2y$10$3i9/lVd8UOFIJ6PAMFt8gu3/r5g0qeCJvoSlLCsvMTythye19F77a'),
        ),
        // 'anonymous' => true
    ),
);

$app['app.token_authenticator'] = function ($app) {
    return new App\Security\TokenAuthenticator($app['security.encoder_factory']);
};

$app->register(new Silex\Provider\SecurityServiceProvider());

return $app;

TokenAuthenticator
与示例相同。如何使用实现
App\Security\EncoderFactoryInterface
的参数配置此服务?您能帮我吗?

缺少use语句:

use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface;

简单介绍一下,能否尝试在TokenAuthenticator.php文件的开头添加
使用Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface
?似乎缺少此接口的命名空间