alexhenriet/common-bundle

Symfony 项目中使用的常用工具

安装: 975

依赖: 0

建议者: 0

安全: 0

星标: 0

关注者: 2

分支: 0

开放问题: 0

类型:symfony-bundle

v0.1.2 2022-05-24 11:50 UTC

This package is auto-updated.

Last update: 2024-09-24 16:58:53 UTC


README

Symfony 项目中使用的常用工具。

如何安装此包?

  1. 在 config/packages/alexhenriet_common.yaml 中创建包配置,在要求包之前(否则在安装过程中您将收到错误,因为此包没有配方)

    common:
        ldap_host: 'ldap-host.lan'
        # ldap_port: 389
        # ldap_opt_protocol_version: 3
        # ldap_opt_referrals: 0
        login_prefix: 'DOMAIN'
        # login_route: 'app_login'
        bypass_user_identifiers: ['MyLogin']
        bypass_environments: ['loc']
    
  2. 使用 composer 安装包

    composer require alexhenriet/common-bundle
    
  3. 在 config/bundles.php 中启用包

    return [
        ...
        Alexhenriet\Bundle\CommonBundle\CommonBundle::class => ['all' => true],
    ];
    

如何使用此包?

自定义认证器

  1. 使用 symfony/maker-bundle 提供的命令生成用户和认证

  2. 在 security.yaml 中替换自定义认证器

    security:
        enable_authenticator_manager: true
    
    firewalls:
        main:
            custom_authenticators:
                - Alexhenriet\Bundle\CommonBundle\Security\BypassableLdapLoginFormAuthenticator
    
  3. 在您的模板\security\login.html.twig 中使用 _username 和 _password 作为输入名称

抽象控制器

  1. 在控制器中扩展抽象控制器

    use Alexhenriet\Bundle\CommonBundle\Controller\AbstractController;
    
    class ActionsController extends AbstractController
    {}
    
  2. 如果您收到错误 "Controller ... cannot be fetched from the container because it is private",请将以下行添加到 services.yaml

    # controllers are imported separately to make sure services can be injected
    # as action arguments even if you don't extend any base controller class
    App\Controller\:
      resource: '../src/Controller/'
      tags: ['controller.service_arguments']
    

免责声明和责任限制

本免费库按“现状”提供,不提供任何保证。在适用法律允许的最大范围内,作者放弃所有明示、暗示、法定或任何其他保证,包括但不限于对特定目的适用性和商誉的暗示保证。在任何情况下,作者都不会因使用或无法使用本库而产生的任何后果性、特殊性、间接性、偶然性或惩罚性损害承担责任,即使作者已被告知此类损害的可能性。某些司法管辖区不允许对暗示保证或后果性或偶然性损害的责任限制,因此上述限制可能不适用于您。本最终用户许可协议(EULA)将根据比利时法律进行解释和执行,不考虑其冲突法原则。任何源于或与本EULA有关的主张或诉讼将仅在任何位于比利时瓦隆区的有管辖权的法院提起。