Skip to content

Commit 57f06a1

Browse files
committed
added new readme
1 parent 9d3364c commit 57f06a1

File tree

1 file changed

+104
-27
lines changed

1 file changed

+104
-27
lines changed

README.md

Lines changed: 104 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
[![Build Status](https://travis-ci.org/browserstack/browserstack-local-php.svg?branch=master)](https://travis-ci.org/browserstack/browserstack-local-php)
44

5-
## Setup
5+
A simple PHP wrapper for BrowserStack Local Binary.
6+
7+
## Installation
68

79
Installation is possible using [Composer](https://getcomposer.org/).
810

@@ -19,41 +21,116 @@ Install all depenedencies:
1921

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

22-
## API
24+
## Example
25+
26+
```
27+
require_once('vendor/autoload.php');
28+
use BrowserStack\Local;
29+
30+
#creates an instance of Local
31+
$bs_local = new Local();
32+
33+
#replace <browserstack-accesskey> with your key. You can also set an environment variable - "BROWSERSTACK_ACCESS_KEY".
34+
$bs_local_args = array("key" => "<browserstack-accesskey>");
35+
36+
#starts the Local instance with the required arguments
37+
$bs_local->start(bs_local_args);
38+
39+
#check if BrowserStack local instance is running
40+
echo $bs_local->isRunning();
41+
42+
#stop the Local instance
43+
$bs_local->stop();
44+
45+
```
46+
47+
## Arguments
48+
49+
Apart from the key, all other BrowserStack Local modifiers are optional. For the full list of modifiers, refer [BrowserStack Local modifiers](https://www.browserstack.com/local-testing#modifiers). For examples, refer below -
50+
51+
#### Verbose Logging
52+
To enable verbose logging -
53+
```
54+
$bs_local_args = array("key" => "<browserstack-accesskey>", "v" => true);
55+
```
2356

24-
### Constructor
57+
#### Folder Testing
58+
To test local folder rather internal server, provide path to folder as value of this option -
59+
```
60+
$bs_local_args = array("key" => "<browserstack-accesskey>", "f" => "/my/awesome/folder");
61+
```
2562

26-
* `new Local()`: creates an instance of Local
63+
#### Force Start
64+
To kill other running Browserstack Local instances -
65+
```
66+
$bs_local_args = array("key" => "<browserstack-accesskey>", "force" => true);
67+
```
2768

28-
### Methods
69+
#### Only Automate
70+
To disable local testing for Live and Screenshots, and enable only Automate -
71+
```
72+
$bs_local_args = array("key" => "<browserstack-accesskey>", "onlyAutomate" => true);
73+
```
2974

30-
* `start(options)`: starts Local instance with options. The options available are detailed below.
31-
* `stop()`: stops the Local instance
32-
* `isRunning()`: checks if Local instance is running
75+
#### Force Local
76+
To route all traffic via local(your) machine -
77+
```
78+
$bs_local_args = array("key" => "<browserstack-accesskey>", "forcelocal" => true);
79+
```
3380

34-
### Options
81+
#### Proxy
82+
To use a proxy for local testing -
3583

36-
* `key`: BrowserStack Access Key
37-
* `v`: Provides verbose logging
38-
* `f`: If you want to test local folder rather internal server, provide path to folder as value of this option
39-
* `force`: Kill other running Browserstack Local
40-
* `only`: Restricts Local Testing access to specified local servers and/or folders
41-
* `forcelocal`: Route all traffic via local machine
42-
* `onlyAutomate`: Disable Live Testing and Screenshots, just test Automate
43-
* `proxyHost`: Hostname/IP of proxy, remaining proxy options are ignored if this option is absent
44-
* `proxyPort`: Port for the proxy, defaults to 3128 when -proxyHost is used
45-
* `proxyUser`: Username for connecting to proxy (Basic Auth Only)
46-
* `proxyPass`: Password for USERNAME, will be ignored if USERNAME is empty or not specified
47-
* `localIdentifier`: If doing simultaneous multiple local testing connections, set this uniquely for different processes
48-
* `hosts`: List of hosts and ports where Local must be enabled for eg. localhost,3000,1,localhost,3001,0
49-
* `logfile`: Path to file where Local logs be saved to
50-
* `binarypath`: Optional path to Local binary
84+
* proxyHost: Hostname/IP of proxy, remaining proxy options are ignored if this option is absent
85+
* proxyPort: Port for the proxy, defaults to 3128 when -proxyHost is used
86+
* proxyUser: Username for connecting to proxy (Basic Auth Only)
87+
* proxyPass: Password for USERNAME, will be ignored if USERNAME is empty or not specified
5188

52-
## Test
89+
```
90+
$bs_local_args = array("key" => "<browserstack-accesskey>", "proxyHost" => "127.0.0.1", "proxyPort" => "8000", "proxyUser" => "user", "proxyPass" => "password");
91+
```
92+
93+
#### Local Identifier
94+
If doing simultaneous multiple local testing connections, set this uniquely for different processes -
95+
```
96+
$bs_local_args = array("key" => "<browserstack-accesskey>", "localIdentifier" => "randomstring");
97+
```
98+
99+
## Additional Arguments
100+
101+
#### Binary Path
102+
103+
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.
104+
Path to specify local Binary path -
105+
```
106+
$bs_local_args = array("key" => "<browserstack-accesskey>", "binarypath" => "/browserstack/BrowserStackLocal");
107+
```
108+
109+
#### Logfile
110+
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.
111+
To specify the path to file where the logs will be saved -
112+
```
113+
$bs_local_args = array("key" => "<browserstack-accesskey>", "logfile" => "/browserstack/logs.txt");
114+
```
115+
116+
## Contribute
53117

54118
Testing is possible using [PHPUnit](https://phpunit.de/).
55119

56-
To run the tests, run the command:
57-
`phpunit`
120+
To run the tests, run the command: `phpunit`
121+
122+
### Reporting bugs
123+
124+
You can submit bug reports either in the Github issue tracker.
125+
126+
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.
127+
128+
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.
129+
130+
### Pull Requests
58131

132+
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.
59133

134+
* Adhere to the coding conventions you see in the surrounding code.
135+
* Include tests, and make sure all tests pass.
136+
* 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.

0 commit comments

Comments
 (0)