diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index a461bae..c6861d5 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-24.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 716aa02..538b60d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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: @@ -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 @@ -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: @@ -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 diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e4c15f..0d4b221 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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` diff --git a/README.md b/README.md index 09b486f..eef75d9 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 206d0a4..82047c2 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 || ^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" : { diff --git a/src/AutoDiscover.php b/src/AutoDiscover.php index fbefca2..2b5d039 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 ee6823d..f9f5461 100644 --- a/src/BrowserFactory.php +++ b/src/BrowserFactory.php @@ -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(); } /** @@ -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); diff --git a/src/Input/KeyboardKeys.php b/src/Input/KeyboardKeys.php index 459c770..331296b 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]); } /**