Php 如何在silex中正确配置多个防火墙?

Php 如何在silex中正确配置多个防火墙?,php,symfony,silex,Php,Symfony,Silex,我正在开发一个项目,其中我想有两个登录表单,一个用于​​该系统和另一个用于访问客户端的系统,我已经配置了以下防火墙 'admin' => array( 'pattern' => '^/.*$', 'anonymous' => true, 'form' => array( 'login_path' => '/', 'check_path' => '/login_check'

我正在开发一个项目,其中我想有两个登录表单,一个用于​​该系统和另一个用于访问客户端的系统,我已经配置了以下防火墙

'admin'       =>  array(
    'pattern'   =>  '^/.*$',
    'anonymous' =>  true,
    'form'      =>  array(
        'login_path' => '/',
        'check_path' => '/login_check',
        'default_target_path' => '/dashboard',
        'always_use_default_target_path' => true,
        'username_parameter' => 'username',
        'password_parameter' => 'password',
        'csrf_parameter' => 'login_token',
        'failure_path' => '/',
    ),
    'logout'    =>  array(
        'logout_path' => '/logout',
        'target' => '/'
    ),
    'users' => $app->factory(function () use ($app) {
        return new Lib\Provider\UserProvider($app);
    })
),
'clients'      =>  array(
    'pattern'   =>  '^/clients',
    'anonymous' =>  true,
    'form'      =>  array(
        'login_path' => '/clients/login',
        'check_path' => '/clients/login_check',
        'default_target_path' => '/clients/admin',
        'always_use_default_target_path' => true,
        'username_parameter' => 'username',
        'password_parameter' => 'password',
        'csrf_parameter' => 'login_token',
        'failure_path' => '/clients',
    ),
    'logout'    =>  array(
        'logout_path' => '/clients/logout',
        'target' => '/clients/login'
    ),
    'users' => $app->factory(function () use ($app) {
        return new Lib\Provider\ClientProvider($app);
    })
)
admin firewall中的“check_path”=>“/login_check”工作正常,但当您想转到客户端防火墙中的check_路径生成的url时,它会标记以下错误

NotFoundHttpException in HttpKernel.php line 134:    
Unable to find the controller for path "/clients/login_check". The route is wrongly configured.
我搜索了几个小时,无法更正此错误。如果您能帮助解决此问题,我将不胜感激


谢谢

看起来“客户端”部分的检查路径不在防火墙后面。由于定义多个防火墙时顺序很重要(第一个匹配模式获胜),我敢打赌您的“管理员”防火墙模式已经捕获了所有URL,因此“/clients”URL被此模式而不是“clients”模式捕获

可能尝试使用“admin”前缀临时重命名您的管理路由,相应地修改防火墙(使用捕获所有“/admin/…”的模式),并告诉我们它是否解决了您的问题,或者返回的错误是否已更改

编辑: 或者只是更改两个防火墙的顺序,以便客户端的防火墙在管理员的防火墙之前匹配路由


干杯。

从你的问题来看,我不确定如果你直接去那里,
/clients/login\u check
路径是否正常工作?嗨,米卡多,我感谢大家的关注,当我执行登录表单并单击以验证凭据时,它会标记错误Wuoooouuuuuuuuuuu Guigzz非常非常感谢您我更改了顺序并打开我的登录工作。。。。。