Skip to content
Merged
4 changes: 2 additions & 2 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ on:
jobs:
phpstan:
name: PHPStan
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04

steps:
- name: Checkout Code
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down
43 changes: 28 additions & 15 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,39 @@ on:
jobs:
tests:
name: PHP ${{ matrix.php }}; Symfony ${{ matrix.symfony }}
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04

strategy:
matrix:
php: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
symfony: ['4', '5', '6', '7']
php: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']
symfony: ['5', '6', '7', '8']
exclude:
- php: '7.4'
symfony: '6'
- php: '7.4'
symfony: '7'
- php: '7.4'
symfony: '8'
- php: '8.0'
symfony: '6'
- php: '8.0'
symfony: '7'
- php: '8.0'
symfony: '8'
- php: '8.1'
symfony: '7'
- php: '8.4'
symfony: '4'
- php: '8.1'
symfony: '8'
- php: '8.2'
symfony: '8'
- php: '8.3'
symfony: '8'
- php: '8.5'
symfony: '5'

steps:
- name: Checkout Code
uses: actions/checkout@v4
uses: actions/checkout@v6

- uses: browser-actions/setup-chrome@v1
with:
Expand All @@ -45,20 +57,12 @@ jobs:
- name: Setup Problem Matchers
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Select Symfony 4
uses: nick-invision/retry@v3
with:
timeout_minutes: 5
max_attempts: 5
command: composer require "symfony/filesystem:^4.0" "symfony/process:^4.0" "symfony/var-dumper:^4.0" --dev --no-update --no-interaction
if: "matrix.symfony == '4'"

- name: Select Symfony 5
uses: nick-invision/retry@v3
with:
timeout_minutes: 5
max_attempts: 5
command: composer require "symfony/filesystem:^5.0" "symfony/process:^5.0" "symfony/var-dumper:^5.0" --dev --no-update --no-interaction
command: composer require "symfony/filesystem:^5.4" "symfony/process:^5.4" "symfony/var-dumper:^5.4" --dev --no-update --no-interaction
if: "matrix.symfony == '5'"

- name: Select Symfony 6
Expand All @@ -77,6 +81,14 @@ jobs:
command: composer require "symfony/filesystem:^7.0" "symfony/process:^7.0" "symfony/var-dumper:^7.0" --dev --no-update --no-interaction
if: "matrix.symfony == '7'"

- name: Select Symfony 8
uses: nick-invision/retry@v3
with:
timeout_minutes: 5
max_attempts: 5
command: composer require "symfony/filesystem:^8.0" "symfony/process:^8.0" "symfony/var-dumper:^8.0" --dev --no-update --no-interaction
if: "matrix.symfony == '8'"

- name: Install Dependencies
uses: nick-invision/retry@v3
with:
Expand All @@ -88,3 +100,4 @@ jobs:
run: vendor/bin/phpunit
env:
CHROME_PATH: /opt/hostedtoolcache/setup-chrome/chromium/122.0.6261.128/x64/chrome
CHROME_NO_SANDBOX: true
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# CHANGELOG


## 1.15.0 (UPCOMING)

* Add PHP 8.5 support
* Add support for using Symfony 8 components
* Remove support for Symfony 4 components
* Add `CHROME_NO_SANDBOX` env var


## 1.14.0 (2025-05-28)

* Use more specific return type in `PageScreenshot::getException`
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Happy browsing!

## Requirements

Requires PHP 7.4-8.4 and a Chrome/Chromium 65+ executable.
Requires PHP 7.4-8.5 and a Chrome/Chromium 65+ executable.

Note that the library is only tested on Linux but is compatible with macOS and Windows.

Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@
],
"require": {
"php": "^7.4.15 || ^8.0.2",
"chrome-php/wrench": "^1.7",
"chrome-php/wrench": "^1.8",
"evenement/evenement": "^3.0.1",
"monolog/monolog": "^1.27.1 || ^2.8 || ^3.2",
"psr/log": "^1.1 || ^2.0 || ^3.0",
"symfony/filesystem": "^4.4 || ^5.0 || ^6.0 || ^7.0",
"symfony/filesystem": "^5.4 || ^6.0 || ^7.0 || ^8.0",
"symfony/polyfill-mbstring": "^1.26",
"symfony/process": "^4.4 || ^5.0 || ^6.0 || ^7.0"
"symfony/process": "^5.4 || ^6.0 || ^7.0 || ^8.0"
},
"require-dev":{
"bamarni/composer-bin-plugin": "^1.8.2",
"phpunit/phpunit": "^9.6.3 || ^10.0.12",
"symfony/var-dumper": "^4.4 || ^5.0 || ^6.0 || ^7.0"
"symfony/var-dumper": "^5.4 || ^6.0 || ^7.0 || ^8.0"
},
"autoload":{
"psr-4" : {
Expand Down
17 changes: 17 additions & 0 deletions src/AutoDiscover.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,21 @@ private static function shellExec(string $command): ?string
return null;
}
}

/**
* Get default browser options from environment variables.
*
* @return array<string, mixed>
*/
public function getDefaultOptions(): array
{
$options = [];

if (\array_key_exists('CHROME_NO_SANDBOX', $_SERVER)
&& \filter_var($_SERVER['CHROME_NO_SANDBOX'], \FILTER_VALIDATE_BOOLEAN)) {
$options['noSandbox'] = true;
}

return $options;
}
}
8 changes: 6 additions & 2 deletions src/BrowserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,13 @@ class BrowserFactory
*/
protected $options = [];

protected $envOptions = [];

public function __construct(?string $chromeBinary = null)
{
$this->chromeBinary = $chromeBinary ?? (new AutoDiscover())->guessChromeBinaryPath();
$autoDiscover = new AutoDiscover();
$this->chromeBinary = $chromeBinary ?? $autoDiscover->guessChromeBinaryPath();
$this->envOptions = $autoDiscover->getDefaultOptions();
}

/**
Expand All @@ -66,7 +70,7 @@ public function __construct(?string $chromeBinary = null)
*/
public function createBrowser(?array $options = null): ProcessAwareBrowser
{
$options ??= $this->options;
$options = \array_merge($this->envOptions, $options ?? $this->options);

// create logger from options
$logger = self::createLogger($options);
Expand Down
2 changes: 1 addition & 1 deletion src/Input/KeyboardKeys.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ protected function isKeyPressed(): bool
*/
public function getKeyCode(): int
{
return \ord($this->currentKey);
return \ord($this->currentKey[0]);
}

/**
Expand Down