定制 bex/behat-extension-driver-locator 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

bex/behat-extension-driver-locator

Composer 安装命令:

composer require bex/behat-extension-driver-locator

包简介

Driver locator tool for behat extensions

README 文档

README

Scrutinizer Code Quality Build Status Build Status

Behat-ExtensionDriverLocator helps you load external drivers/services (like image uploaders, output formatters, etc) dinamically. The DriverLocator can find you a service in a preconfigured namespace by a given driverkey.

  • It validates that the class implements the DriverInterface or your specific interface.
  • It will call the configure method of the driver to get the config tree of the driver specific configurations
  • It will validate the loaded config against the provided config tree.
  • It will pass the valid config and the DI container to the load method of the driver in order to get a properly loaded service. The package also provide a Driver Node Builder which can create the drivers node for your behat extension. (see usage below)

Installation

Install by adding to your composer.json:

composer require --dev bex/behat-extension-driver-locator

Usage

  1. In your behat extension's configure method use the Driver Node Builder to build the drivers configuration node:

        $driverNodeBuilder = DriverNodeBuilder::getInstance($driverNamespace, $driverParent);
        $driverNodeBuilder->buildDriverNodes($builder, $activeDriversNodeName, $driversCofigurationNodeName, $defaultDriverKeys);

    where:

    • the $driverNamespace is the namespace where the DriverNodeBuilder should look for the drivers when validating a given driver key e.g.: My\\Awesome\\BehatExtension\\Driver
    • the $driverParent is the parent class/interface which should be implemented by all driver e.g.: My\\Awesome\\BehatExtension\\Driver\\MyAwesomeDriverInterface (note that all driver need to implement the Bex\Behat\ExtensionDriverLocator\DriverInterface)
    • the $builder is an Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition instance which you get in your behat extension's configure method as a parameter, the DriverNodeBuilder will add the drivers node to this builder.
    • the $activeDriversNodeName is the name of the node where the user will be able to specify which driver should be used for your extension e.g.: active_my_awesome_drivers
    • the driversCofigurationNodeName is the name of the drivers node, the additional configuration of all driver will be under this node e.g.: my_awesome_drivers
    • the $defaultDriverKeys is the driverkey of the default driver(s) which will be used when the config is empty in the behat.yml e.g.: first_awesomeness
    • Note: The driverkey is always the lowercased and underlined version of the driver's classname. e.g. FirstAwesomeness -> first_awesomeness e.g. First -> first

    With the example configurations a valid config would look like this:

    default:
      extensions:
       My\\Awesome\\BehatExtension: ~

    or

    default:
      extensions:
       My\\Awesome\\BehatExtension:
         active_my_awesome_drivers: first_awesomeness
         my_awesome_drivers:
           first_awesomeness:
             # ... all driver specific configuration goes here ...
  2. In your behat extension's load method use the Driver Locator to load the active driver(s): Note that it will validate the driver specific configs automatically.

        $driverLocator = DriverLocator::getInstance($driverNamespace, $driverParent);
        $drivers = $driverLocator->findDrivers($container, $activeDrivers, $driverConfigs);

    where:

    • the $driverNamespace is the namespace where the DriverLocator should look for the drivers e.g.: My\\Awesome\\BehatExtension\\Driver
    • the $driverParent is the parent class/interface which should be implemented by all driver e.g.: My\\Awesome\\BehatExtension\\Driver\\MyAwesomeDriverInterface
    • the $container is an Symfony\Component\DependencyInjection\ContainerBuilder instance which you get in your behat extension's load method as a parameter, the DriverLocator will pass this container to the load method of each driver
    • the $activeDrivers are the active image drivers from the $config param which you get in the load method e.g.: $config['active_my_awesome_drivers']
    • the $driverConfigs are the driver specific configuration values from the $config param e.g.: $config['my_awesome_drivers']

bex/behat-extension-driver-locator 适用场景与选型建议

bex/behat-extension-driver-locator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.27M 次下载、GitHub Stars 达 38, 最近一次更新时间为 2015 年 11 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「BDD」 「Behat」 「TDD」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 bex/behat-extension-driver-locator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 bex/behat-extension-driver-locator 我们能提供哪些服务?
定制开发 / 二次开发

基于 bex/behat-extension-driver-locator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 5.27M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 38
  • 点击次数: 31
  • 依赖项目数: 4
  • 推荐数: 0

GitHub 信息

  • Stars: 38
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-11-13