Skip to content

Commit 13f9cf7

Browse files
[1.15] Add support for PHP 8.5 and Symfony 8 (#720)
* Add support for PHP 8.5 and Symfony 8 * Update static.yml * Update tests.yml * Update tests.yml * Add `CHROME_NO_SANDBOX` env var * Update composer.json * Update BrowserFactory.php * Update tests.yml * temp * Fixes * Update tests.yml * Restored closer to original browser factory options semantics * Update CHANGELOG.md
1 parent cf6c03a commit 13f9cf7

File tree

8 files changed

+67
-25
lines changed

8 files changed

+67
-25
lines changed

.github/workflows/static.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ on:
77
jobs:
88
phpstan:
99
name: PHPStan
10-
runs-on: ubuntu-22.04
10+
runs-on: ubuntu-24.04
1111

1212
steps:
1313
- name: Checkout Code
14-
uses: actions/checkout@v4
14+
uses: actions/checkout@v6
1515

1616
- name: Setup PHP
1717
uses: shivammathur/setup-php@v2

.github/workflows/tests.yml

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,39 @@ on:
77
jobs:
88
tests:
99
name: PHP ${{ matrix.php }}; Symfony ${{ matrix.symfony }}
10-
runs-on: ubuntu-22.04
10+
runs-on: ubuntu-24.04
1111

1212
strategy:
1313
matrix:
14-
php: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
15-
symfony: ['4', '5', '6', '7']
14+
php: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']
15+
symfony: ['5', '6', '7', '8']
1616
exclude:
1717
- php: '7.4'
1818
symfony: '6'
1919
- php: '7.4'
2020
symfony: '7'
21+
- php: '7.4'
22+
symfony: '8'
23+
- php: '8.0'
24+
symfony: '6'
2125
- php: '8.0'
2226
symfony: '7'
27+
- php: '8.0'
28+
symfony: '8'
2329
- php: '8.1'
2430
symfony: '7'
25-
- php: '8.4'
26-
symfony: '4'
31+
- php: '8.1'
32+
symfony: '8'
33+
- php: '8.2'
34+
symfony: '8'
35+
- php: '8.3'
36+
symfony: '8'
37+
- php: '8.5'
38+
symfony: '5'
2739

2840
steps:
2941
- name: Checkout Code
30-
uses: actions/checkout@v4
42+
uses: actions/checkout@v6
3143

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

48-
- name: Select Symfony 4
49-
uses: nick-invision/retry@v3
50-
with:
51-
timeout_minutes: 5
52-
max_attempts: 5
53-
command: composer require "symfony/filesystem:^4.0" "symfony/process:^4.0" "symfony/var-dumper:^4.0" --dev --no-update --no-interaction
54-
if: "matrix.symfony == '4'"
55-
5660
- name: Select Symfony 5
5761
uses: nick-invision/retry@v3
5862
with:
5963
timeout_minutes: 5
6064
max_attempts: 5
61-
command: composer require "symfony/filesystem:^5.0" "symfony/process:^5.0" "symfony/var-dumper:^5.0" --dev --no-update --no-interaction
65+
command: composer require "symfony/filesystem:^5.4" "symfony/process:^5.4" "symfony/var-dumper:^5.4" --dev --no-update --no-interaction
6266
if: "matrix.symfony == '5'"
6367

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

84+
- name: Select Symfony 8
85+
uses: nick-invision/retry@v3
86+
with:
87+
timeout_minutes: 5
88+
max_attempts: 5
89+
command: composer require "symfony/filesystem:^8.0" "symfony/process:^8.0" "symfony/var-dumper:^8.0" --dev --no-update --no-interaction
90+
if: "matrix.symfony == '8'"
91+
8092
- name: Install Dependencies
8193
uses: nick-invision/retry@v3
8294
with:
@@ -88,3 +100,4 @@ jobs:
88100
run: vendor/bin/phpunit
89101
env:
90102
CHROME_PATH: /opt/hostedtoolcache/setup-chrome/chromium/122.0.6261.128/x64/chrome
103+
CHROME_NO_SANDBOX: true

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
# CHANGELOG
22

33

4+
## 1.15.0 (UPCOMING)
5+
6+
* Add PHP 8.5 support
7+
* Add support for using Symfony 8 components
8+
* Remove support for Symfony 4 components
9+
* Add `CHROME_NO_SANDBOX` env var
10+
11+
412
## 1.14.0 (2025-05-28)
513

614
* Use more specific return type in `PageScreenshot::getException`

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Happy browsing!
2424

2525
## Requirements
2626

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

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

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@
1717
],
1818
"require": {
1919
"php": "^7.4.15 || ^8.0.2",
20-
"chrome-php/wrench": "^1.7",
20+
"chrome-php/wrench": "^1.8",
2121
"evenement/evenement": "^3.0.1",
2222
"monolog/monolog": "^1.27.1 || ^2.8 || ^3.2",
2323
"psr/log": "^1.1 || ^2.0 || ^3.0",
24-
"symfony/filesystem": "^4.4 || ^5.0 || ^6.0 || ^7.0",
24+
"symfony/filesystem": "^5.4 || ^6.0 || ^7.0 || ^8.0",
2525
"symfony/polyfill-mbstring": "^1.26",
26-
"symfony/process": "^4.4 || ^5.0 || ^6.0 || ^7.0"
26+
"symfony/process": "^5.4 || ^6.0 || ^7.0 || ^8.0"
2727
},
2828
"require-dev":{
2929
"bamarni/composer-bin-plugin": "^1.8.2",
3030
"phpunit/phpunit": "^9.6.3 || ^10.0.12",
31-
"symfony/var-dumper": "^4.4 || ^5.0 || ^6.0 || ^7.0"
31+
"symfony/var-dumper": "^5.4 || ^6.0 || ^7.0 || ^8.0"
3232
},
3333
"autoload":{
3434
"psr-4" : {

src/AutoDiscover.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,21 @@ private static function shellExec(string $command): ?string
6969
return null;
7070
}
7171
}
72+
73+
/**
74+
* Get default browser options from environment variables.
75+
*
76+
* @return array<string, mixed>
77+
*/
78+
public function getDefaultOptions(): array
79+
{
80+
$options = [];
81+
82+
if (\array_key_exists('CHROME_NO_SANDBOX', $_SERVER)
83+
&& \filter_var($_SERVER['CHROME_NO_SANDBOX'], \FILTER_VALIDATE_BOOLEAN)) {
84+
$options['noSandbox'] = true;
85+
}
86+
87+
return $options;
88+
}
7289
}

src/BrowserFactory.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,13 @@ class BrowserFactory
5050
*/
5151
protected $options = [];
5252

53+
protected $envOptions = [];
54+
5355
public function __construct(?string $chromeBinary = null)
5456
{
55-
$this->chromeBinary = $chromeBinary ?? (new AutoDiscover())->guessChromeBinaryPath();
57+
$autoDiscover = new AutoDiscover();
58+
$this->chromeBinary = $chromeBinary ?? $autoDiscover->guessChromeBinaryPath();
59+
$this->envOptions = $autoDiscover->getDefaultOptions();
5660
}
5761

5862
/**
@@ -66,7 +70,7 @@ public function __construct(?string $chromeBinary = null)
6670
*/
6771
public function createBrowser(?array $options = null): ProcessAwareBrowser
6872
{
69-
$options ??= $this->options;
73+
$options = \array_merge($this->envOptions, $options ?? $this->options);
7074

7175
// create logger from options
7276
$logger = self::createLogger($options);

src/Input/KeyboardKeys.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ protected function isKeyPressed(): bool
172172
*/
173173
public function getKeyCode(): int
174174
{
175-
return \ord($this->currentKey);
175+
return \ord($this->currentKey[0]);
176176
}
177177

178178
/**

0 commit comments

Comments
 (0)