Skip to content

Commit

Permalink
add option customFlags
Browse files Browse the repository at this point in the history
  • Loading branch information
gsouf committed Oct 2, 2018
1 parent ba93f92 commit a1894ca
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* Added option ``"nosandbox"`` for browser factory
* Added option ``"sendSyncDefaultTimeout"`` for browser factory
* Added option ``"ignoreCertificateErrors"`` for browser factory
* Added option ``"customFlags"`` for browser factory
* Bug fixes:
* Fixed user agent string for browser factory

Expand Down
29 changes: 15 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,21 @@ API

Here are the options available for the browser factory:

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

### Browser API

Expand Down
5 changes: 5 additions & 0 deletions src/Browser/BrowserProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,11 @@ private function getArgsFromOptions(array $options)
$args[] = '--ignore-certificate-errors';
}

// add custom flags
if (array_key_exists('customFlags', $options) && is_array($options['customFlags'])) {
$args = array_merge($args, $options['customFlags']);
}

// add user data dir to args
$args[] = '--user-data-dir=' . $options['userDataDir'];

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

0 comments on commit a1894ca

Please sign in to comment.