From 111bed0f027bff3580e55458d62c2acf2f598a13 Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Sat, 27 Dec 2025 11:31:43 +0000 Subject: [PATCH 01/13] Add support for PHP 8.5 and Symfony 8 --- .github/workflows/static.yml | 4 ++-- .github/workflows/tests.yml | 26 +++++++++++++------------- CHANGELOG.md | 7 +++++++ README.md | 2 +- composer.json | 8 ++++---- 5 files changed, 27 insertions(+), 20 deletions(-) diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index a461bae2..c7cf6fb9 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -7,11 +7,11 @@ on: jobs: phpstan: name: PHPStan - runs-on: ubuntu-22.04 + runs-on: ubuntu-25.04 steps: - name: Checkout Code - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Setup PHP uses: shivammathur/setup-php@v2 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 716aa028..259ed9b0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,12 +7,12 @@ 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' @@ -27,7 +27,7 @@ jobs: steps: - name: Checkout Code - uses: actions/checkout@v4 + uses: actions/checkout@v6 - uses: browser-actions/setup-chrome@v1 with: @@ -45,20 +45,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 @@ -77,6 +69,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: diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e4c15f7..0187b1cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,13 @@ # CHANGELOG +## 1.15.0 (UPCOMING) + +* Add PHP 8.5 support +* Add support for using Symfony 8 components +* Remove support for Symfony 4 components + + ## 1.14.0 (2025-05-28) * Use more specific return type in `PageScreenshot::getException` diff --git a/README.md b/README.md index 09b486f6..eef75d93 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/composer.json b/composer.json index 206d0a40..34e26504 100644 --- a/composer.json +++ b/composer.json @@ -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 || ^6.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" : { From ca71d3e4bea204a87a4dbe09b5733c1c23e83596 Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Sat, 27 Dec 2025 11:32:21 +0000 Subject: [PATCH 02/13] Update static.yml --- .github/workflows/static.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index c7cf6fb9..c6861d5f 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -7,7 +7,7 @@ on: jobs: phpstan: name: PHPStan - runs-on: ubuntu-25.04 + runs-on: ubuntu-24.04 steps: - name: Checkout Code From 320f39c9d63b3d6ca07e0114dc445c02d27eba66 Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Sat, 27 Dec 2025 11:33:42 +0000 Subject: [PATCH 03/13] Update tests.yml --- .github/workflows/tests.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 259ed9b0..67b2efb2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -18,12 +18,18 @@ jobs: symfony: '6' - php: '7.4' symfony: '7' + - php: '7.4' + symfony: '8' - php: '8.0' symfony: '7' - php: '8.1' symfony: '7' - - php: '8.4' - symfony: '4' + - php: '8.1' + symfony: '8' + - php: '8.2' + symfony: '8' + - php: '8.5' + symfony: '5' steps: - name: Checkout Code From c119b1ce53d94a6d4efc91a39bd2d21062879448 Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Sat, 27 Dec 2025 11:34:03 +0000 Subject: [PATCH 04/13] Update tests.yml --- .github/workflows/tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 67b2efb2..f14f3ab1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -28,6 +28,8 @@ jobs: symfony: '8' - php: '8.2' symfony: '8' + - php: '8.3' + symfony: '8' - php: '8.5' symfony: '5' From 98bb9e2f7d4bb0731867fca1f58133bfd4c35c97 Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Sat, 27 Dec 2025 11:49:46 +0000 Subject: [PATCH 05/13] Add `CHROME_NO_SANDBOX` env var --- .github/workflows/tests.yml | 1 + CHANGELOG.md | 2 ++ src/AutoDiscover.php | 17 +++++++++++++++++ src/BrowserFactory.php | 6 ++++-- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f14f3ab1..cebb6cd6 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -96,3 +96,4 @@ jobs: run: vendor/bin/phpunit env: CHROME_PATH: /opt/hostedtoolcache/setup-chrome/chromium/122.0.6261.128/x64/chrome + CHROME_NO_SANDBOX: true diff --git a/CHANGELOG.md b/CHANGELOG.md index 0187b1cb..44a88b2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ * Add PHP 8.5 support * Add support for using Symfony 8 components * Remove support for Symfony 4 components +* Merge options with defaults in factory +* Add `CHROME_NO_SANDBOX` env var ## 1.14.0 (2025-05-28) diff --git a/src/AutoDiscover.php b/src/AutoDiscover.php index fbefca21..2b5d0397 100644 --- a/src/AutoDiscover.php +++ b/src/AutoDiscover.php @@ -69,4 +69,21 @@ private static function shellExec(string $command): ?string return null; } } + + /** + * Get default browser options from environment variables. + * + * @return array + */ + 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; + } } diff --git a/src/BrowserFactory.php b/src/BrowserFactory.php index ee6823de..7f278e4b 100644 --- a/src/BrowserFactory.php +++ b/src/BrowserFactory.php @@ -52,7 +52,9 @@ class BrowserFactory public function __construct(?string $chromeBinary = null) { - $this->chromeBinary = $chromeBinary ?? (new AutoDiscover())->guessChromeBinaryPath(); + $autoDiscover = new AutoDiscover(); + $this->chromeBinary = $chromeBinary ?? $autoDiscover->guessChromeBinaryPath(); + $this->options = \array_merge($this->options, $autoDiscover->getDefaultOptions()); } /** @@ -66,7 +68,7 @@ public function __construct(?string $chromeBinary = null) */ public function createBrowser(?array $options = null): ProcessAwareBrowser { - $options ??= $this->options; + $options = \array_merge($this->options, $options ?? []); // create logger from options $logger = self::createLogger($options); From 8de6ff190591aa6f84e8c2ee3edb54036afe2c04 Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Sat, 27 Dec 2025 11:50:46 +0000 Subject: [PATCH 06/13] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 34e26504..82047c23 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "evenement/evenement": "^3.0.1", "monolog/monolog": "^1.27.1 || ^2.8 || ^3.2", "psr/log": "^1.1 || ^2.0 || ^3.0", - "symfony/filesystem": "^5.4 || ^6.0 || ^7.0 || ^6.0", + "symfony/filesystem": "^5.4 || ^6.0 || ^7.0 || ^8.0", "symfony/polyfill-mbstring": "^1.26", "symfony/process": "^5.4 || ^6.0 || ^7.0 || ^8.0" }, From 94f4a095280aa756f2b5909650eeccdfc4824e57 Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Sat, 27 Dec 2025 11:57:29 +0000 Subject: [PATCH 07/13] Update BrowserFactory.php --- src/BrowserFactory.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/BrowserFactory.php b/src/BrowserFactory.php index 7f278e4b..2292c0bb 100644 --- a/src/BrowserFactory.php +++ b/src/BrowserFactory.php @@ -50,11 +50,13 @@ class BrowserFactory */ protected $options = []; + protected $envOptions = []; + public function __construct(?string $chromeBinary = null) { $autoDiscover = new AutoDiscover(); $this->chromeBinary = $chromeBinary ?? $autoDiscover->guessChromeBinaryPath(); - $this->options = \array_merge($this->options, $autoDiscover->getDefaultOptions()); + $this->envOptions = $autoDiscover->getDefaultOptions(); } /** @@ -68,7 +70,7 @@ public function __construct(?string $chromeBinary = null) */ public function createBrowser(?array $options = null): ProcessAwareBrowser { - $options = \array_merge($this->options, $options ?? []); + $options = \array_merge($this->envOptions, $this->options, $options ?? []); // create logger from options $logger = self::createLogger($options); From 7ea359e8dead017df30553ce4d54ccdd379eca2e Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Sat, 27 Dec 2025 12:00:02 +0000 Subject: [PATCH 08/13] Update tests.yml --- .github/workflows/tests.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index cebb6cd6..cf518fc8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -22,6 +22,8 @@ jobs: symfony: '8' - php: '8.0' symfony: '7' + - php: '8.0' + symfony: '8' - php: '8.1' symfony: '7' - php: '8.1' @@ -93,7 +95,7 @@ jobs: command: composer update --no-interaction --no-progress - name: Execute PHPUnit - run: vendor/bin/phpunit + run: vendor/bin/phpunit --display-deprecations env: CHROME_PATH: /opt/hostedtoolcache/setup-chrome/chromium/122.0.6261.128/x64/chrome CHROME_NO_SANDBOX: true From 481c7589fbb53e76e41691dfdbc4dc1d23d3f1f3 Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Sat, 27 Dec 2025 12:03:23 +0000 Subject: [PATCH 09/13] temp --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index cf518fc8..e48f06f9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,7 +11,7 @@ jobs: strategy: matrix: - php: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5'] + php: ['8.2', '8.3', '8.4', '8.5'] symfony: ['5', '6', '7', '8'] exclude: - php: '7.4' From 21a128287e8bb9be6fa55fd614a892c65c52721d Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Sat, 27 Dec 2025 12:14:19 +0000 Subject: [PATCH 10/13] Fixes --- .github/workflows/tests.yml | 4 ++-- src/Input/KeyboardKeys.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e48f06f9..d12ea1fc 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,7 +11,7 @@ jobs: strategy: matrix: - php: ['8.2', '8.3', '8.4', '8.5'] + php: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5'] symfony: ['5', '6', '7', '8'] exclude: - php: '7.4' @@ -95,7 +95,7 @@ jobs: command: composer update --no-interaction --no-progress - name: Execute PHPUnit - run: vendor/bin/phpunit --display-deprecations + run: vendor/bin/phpunit env: CHROME_PATH: /opt/hostedtoolcache/setup-chrome/chromium/122.0.6261.128/x64/chrome CHROME_NO_SANDBOX: true diff --git a/src/Input/KeyboardKeys.php b/src/Input/KeyboardKeys.php index 459c7705..331296b1 100644 --- a/src/Input/KeyboardKeys.php +++ b/src/Input/KeyboardKeys.php @@ -172,7 +172,7 @@ protected function isKeyPressed(): bool */ public function getKeyCode(): int { - return \ord($this->currentKey); + return \ord($this->currentKey[0]); } /** From 03cfa0446535644c54a8bc733cdd8c2fe013f6ab Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Sat, 27 Dec 2025 12:17:26 +0000 Subject: [PATCH 11/13] Update tests.yml --- .github/workflows/tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d12ea1fc..538b60dc 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -20,6 +20,8 @@ jobs: symfony: '7' - php: '7.4' symfony: '8' + - php: '8.0' + symfony: '6' - php: '8.0' symfony: '7' - php: '8.0' From 0ecd3022cc51ff940cee65d2b5bfeb6882bb3e2d Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Sat, 27 Dec 2025 12:20:07 +0000 Subject: [PATCH 12/13] Restored closer to original browser factory options semantics --- src/BrowserFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BrowserFactory.php b/src/BrowserFactory.php index 2292c0bb..f9f54614 100644 --- a/src/BrowserFactory.php +++ b/src/BrowserFactory.php @@ -70,7 +70,7 @@ public function __construct(?string $chromeBinary = null) */ public function createBrowser(?array $options = null): ProcessAwareBrowser { - $options = \array_merge($this->envOptions, $this->options, $options ?? []); + $options = \array_merge($this->envOptions, $options ?? $this->options); // create logger from options $logger = self::createLogger($options); From 6e6f1f45569372a4009422f3fc9713430788cbe7 Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Sat, 27 Dec 2025 12:22:55 +0000 Subject: [PATCH 13/13] Update CHANGELOG.md --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44a88b2f..0d4b2218 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,6 @@ * Add PHP 8.5 support * Add support for using Symfony 8 components * Remove support for Symfony 4 components -* Merge options with defaults in factory * Add `CHROME_NO_SANDBOX` env var