bex/behat-extension-driver-locator
Composer 安装命令:
composer require bex/behat-extension-driver-locator
包简介
Driver locator tool for behat extensions
README 文档
README
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
-
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
$driverNamespaceis the namespace where the DriverNodeBuilder should look for the drivers when validating a given driver key e.g.:My\\Awesome\\BehatExtension\\Driver - the
$driverParentis 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 theBex\Behat\ExtensionDriverLocator\DriverInterface) - the
$builderis anSymfony\Component\Config\Definition\Builder\ArrayNodeDefinitioninstance which you get in your behat extension's configure method as a parameter, the DriverNodeBuilder will add the drivers node to this builder. - the
$activeDriversNodeNameis 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
driversCofigurationNodeNameis the name of the drivers node, the additional configuration of all driver will be under this node e.g.:my_awesome_drivers - the
$defaultDriverKeysis 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 ...
- the
-
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
$driverNamespaceis the namespace where the DriverLocator should look for the drivers e.g.:My\\Awesome\\BehatExtension\\Driver - the
$driverParentis the parent class/interface which should be implemented by all driver e.g.:My\\Awesome\\BehatExtension\\Driver\\MyAwesomeDriverInterface - the
$containeris anSymfony\Component\DependencyInjection\ContainerBuilderinstance 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
$activeDriversare the active image drivers from the $config param which you get in the load method e.g.: $config['active_my_awesome_drivers'] - the
$driverConfigsare the driver specific configuration values from the $config param e.g.: $config['my_awesome_drivers']
- the
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 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 bex/behat-extension-driver-locator 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Helper that decorates any SUS with a phpspec lazy object wrapper
Behat Context for testing Symfony Api
A Behat Extension that allows custom bootstrapping
Environment processor and contexts autoloader
Provides access to magento2 object manager from behat and allows to change magento config settings temporarly
log the behat execution into json result
统计信息
- 总下载量: 5.27M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 38
- 点击次数: 31
- 依赖项目数: 4
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-11-13