定制 browserstack/browserstack-local 二次开发

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

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

browserstack/browserstack-local

Composer 安装命令:

composer require browserstack/browserstack-local

包简介

PHP bindings for BrowserStack Local

README 文档

README

Build Status

PHP bindings for BrowserStack Local.

Installation

Installation is possible using Composer.

If you don't already use Composer, you can download the composer.phar binary:

curl -sS https://getcomposer.org/installer | php

Then install the library:

`php composer.phar require browserstack/browserstack-local`

Install all depenedencies: php composer.phar install

Test the installation by running a simple test file, check out example.php in the main repository.

Example

require_once('vendor/autoload.php');
use BrowserStack\Local;

#creates an instance of Local
$bs_local = new Local();

#replace <browserstack-accesskey> with your key. You can also set an environment variable - "BROWSERSTACK_ACCESS_KEY".
$bs_local_args = array("key" => "<browserstack-accesskey>");

#starts the Local instance with the required arguments
$bs_local->start(bs_local_args);

#check if BrowserStack local instance is running
echo $bs_local->isRunning();

#stop the Local instance
$bs_local->stop();

Arguments

Apart from the key, all other BrowserStack Local modifiers are optional. For the full list of modifiers, refer BrowserStack Local modifiers. For examples, refer below -

Verbose Logging

To enable verbose logging -

$bs_local_args = array("key" => "<browserstack-accesskey>", "v" => true);

Folder Testing

To test local folder rather internal server, provide path to folder as value of this option -

$bs_local_args = array("key" => "<browserstack-accesskey>", "f" => "/my/awesome/folder");

Force Start

To kill other running Browserstack Local instances -

$bs_local_args = array("key" => "<browserstack-accesskey>", "force" => true);

Only Automate

To disable local testing for Live and Screenshots, and enable only Automate -

$bs_local_args = array("key" => "<browserstack-accesskey>", "onlyAutomate" => true);

Force Local

To route all traffic via local(your) machine -

$bs_local_args = array("key" => "<browserstack-accesskey>", "forcelocal" => true);

Proxy

To use a proxy for local testing -

  • proxyHost: Hostname/IP of proxy, remaining proxy options are ignored if this option is absent
  • proxyPort: Port for the proxy, defaults to 3128 when -proxyHost is used
  • proxyUser: Username for connecting to proxy (Basic Auth Only)
  • proxyPass: Password for USERNAME, will be ignored if USERNAME is empty or not specified
$bs_local_args = array("key" => "<browserstack-accesskey>", "proxyHost" => "127.0.0.1", "proxyPort" => "8000", "proxyUser" => "user", "proxyPass" => "password");

Local Proxy

To use local proxy in local testing -

  • localProxyHost: Hostname/IP of proxy, remaining proxy options are ignored if this option is absent
  • localProxyPort: Port for the proxy, defaults to 8081 when -localProxyHost is used
  • localProxyUser: Username for connecting to proxy (Basic Auth Only)
  • localProxyPass: Password for USERNAME, will be ignored if USERNAME is empty or not specified
$bs_local_args = array("key" => "<browserstack-accesskey>", "localProxyHost" => "127.0.0.1", "localProxyPort" => "8000", "-localProxyUser" => "user", "-localProxyPass" => "password");

PAC (Proxy Auto-Configuration)

To use PAC (Proxy Auto-Configuration) in local testing -

  • pac-file: PAC (Proxy Auto-Configuration) file’s absolute path
$bs_local_args = array("key" => "<browserstack-accesskey>", "-pac-file" => "<pac_file_abs_path>");

Local Identifier

If doing simultaneous multiple local testing connections, set this uniquely for different processes -

$bs_local_args = array("key" => "<browserstack-accesskey>", "localIdentifier" => "randomstring");

Additional Arguments

Binary Path

By default, BrowserStack local wrappers try downloading and executing the latest version of BrowserStack binary in ~/.browserstack or the present working directory or the tmp folder by order. But you can override these by passing the -binarypath argument. Path to specify local Binary path -

$bs_local_args = array("key" => "<browserstack-accesskey>", "binarypath" => "/browserstack/BrowserStackLocal");

Logfile

To save the logs to the file while running with the '-v' argument, you can specify the path of the file. By default the logs are saved in the local.log file in the present woring directory. To specify the path to file where the logs will be saved -

$bs_local_args = array("key" => "<browserstack-accesskey>", "logfile" => "/browserstack/logs.txt");

Contribute

Testing is possible using PHPUnit.

To run the tests, run the command: phpunit

Reporting bugs

You can submit bug reports either in the Github issue tracker.

Before submitting an issue please check if there is already an existing issue. If there is, please add any additional information give it a "+1" in the comments.

When submitting an issue please describe the issue clearly, including how to reproduce the bug, which situations it appears in, what you expect to happen, what actually happens, and what platform (operating system and version) you are using.

Pull Requests

We love pull requests! We are very happy to work with you to get your changes merged in, however, please keep the following in mind.

  • Adhere to the coding conventions you see in the surrounding code.
  • Include tests, and make sure all tests pass.
  • Before submitting a pull-request, clean up the git history by going over your commits and squashing together minor changes and fixes into the corresponding commits. You can do this using the interactive rebase command.

browserstack/browserstack-local 适用场景与选型建议

browserstack/browserstack-local 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.69M 次下载、GitHub Stars 达 15, 最近一次更新时间为 2016 年 05 月 02 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 browserstack/browserstack-local 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 1.69M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 15
  • 点击次数: 23
  • 依赖项目数: 5
  • 推荐数: 0

GitHub 信息

  • Stars: 15
  • Watchers: 15
  • Forks: 10
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-05-02