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
?似乎缺少此接口的命名空间