Skip to content

Commit a1894ca

Browse files
committed
add option customFlags
1 parent ba93f92 commit a1894ca

File tree

4 files changed

+22
-14
lines changed

4 files changed

+22
-14
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
* Added option ``"nosandbox"`` for browser factory
2424
* Added option ``"sendSyncDefaultTimeout"`` for browser factory
2525
* Added option ``"ignoreCertificateErrors"`` for browser factory
26+
* Added option ``"customFlags"`` for browser factory
2627
* Bug fixes:
2728
* Fixed user agent string for browser factory
2829

README.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -127,20 +127,21 @@ API
127127

128128
Here are the options available for the browser factory:
129129

130-
| Option name | Default | Description |
131-
|--------------------|-----------------------|-----------------------------------------------------------------------------------|
132-
| connectionDelay | 0 | Delay to apply between each operation for debugging purposes |
133-
| debug | false | Allows to enable debug mode |
134-
| debugLogger | null | A string (e.g "php://stdout"), or resource, or PSR-3 logger instance to print debug messages |
135-
| enableImages | true | Toggles loading of images |
136-
| headless | true | Enable or disable headless mode |
137-
| ignoreCertificateErrors | false | Set chrome to ignore ssl errors |
138-
| noSandbox | false | Useful to run in a docker container |
139-
| sendSyncDefaultTimeout | 3000 | Default timeout (ms) for sending sync messages |
140-
| startupTimeout | 30 | Maximum time in seconds to wait for chrome to start |
141-
| userAgent | none | User agent to use for the whole browser (see page api for alternative) |
142-
| userDataDir | none | chrome user data dir (default: a new empty dir is generated temporarily) |
143-
| windowSize | none | Size of the window. usage: ``[$width, $height]`` - see also Page::setViewportSize |
130+
| Option name | Default | Description |
131+
|--------------------|---------------|--------------------------------------------------------------------------------------------------|
132+
| connectionDelay | 0 | Delay to apply between each operation for debugging purposes |
133+
| customFlags | none | Array of flags to pass to the command line. Eg: ``['--option1', '--option2=someValue']`` |
134+
| debug | false | Allows to enable debug mode |
135+
| debugLogger | null | A string (e.g "php://stdout"), or resource, or PSR-3 logger instance to print debug messages |
136+
| enableImages | true | Toggles loading of images |
137+
| headless | true | Enable or disable headless mode |
138+
| ignoreCertificateErrors | false | Set chrome to ignore ssl errors |
139+
| noSandbox | false | Useful to run in a docker container |
140+
| sendSyncDefaultTimeout | 3000 | Default timeout (ms) for sending sync messages |
141+
| startupTimeout | 30 | Maximum time in seconds to wait for chrome to start |
142+
| userAgent | none | User agent to use for the whole browser (see page api for alternative) |
143+
| userDataDir | none | chrome user data dir (default: a new empty dir is generated temporarily) |
144+
| windowSize | none | Size of the window. usage: ``[$width, $height]`` - see also Page::setViewportSize |
144145

145146
### Browser API
146147

src/Browser/BrowserProcess.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,11 @@ private function getArgsFromOptions(array $options)
333333
$args[] = '--ignore-certificate-errors';
334334
}
335335

336+
// add custom flags
337+
if (array_key_exists('customFlags', $options) && is_array($options['customFlags'])) {
338+
$args = array_merge($args, $options['customFlags']);
339+
}
340+
336341
// add user data dir to args
337342
$args[] = '--user-data-dir=' . $options['userDataDir'];
338343

src/BrowserFactory.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public function __construct(string $chromeBinaries = null)
3535
*
3636
* @param array $options options for browser creation:
3737
* - connectionDelay: amount of time in seconds to slows down connection for debugging purposes (default: none)
38+
* - customFlags: array of custom flag to flags to pass to the command line
3839
* - debug: toggles the debug mode that allows to print additional details (default: false)
3940
* - debugLogger: resource string ("php://stdout"), resource or psr-3 logger instance (default: none)
4041
* enabling debug logger will also enable debug mode.

0 commit comments

Comments
 (0)