PHPackages                             systemaworking/puphpeteer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. systemaworking/puphpeteer

ActiveLibrary[Testing &amp; Quality](/categories/testing)

systemaworking/puphpeteer
=========================

A Puppeteer bridge for PHP, supporting the entire API.

v2.2(2y ago)0234MITPHPPHP ^8.0

Since Jan 5Pushed 2y agoCompare

[ Source](https://github.com/systemaworking/puphpeteer)[ Packagist](https://packagist.org/packages/systemaworking/puphpeteer)[ RSS](/packages/systemaworking-puphpeteer/feed)WikiDiscussions zoon Synced 1mo ago

READMEChangelog (1)Dependencies (13)Versions (2)Used By (0)

PuPHPeteer
==========

[](#puphpeteer)

[![](https://user-images.githubusercontent.com/817508/100672192-dd258500-3361-11eb-845f-e8b5109752e4.png)](https://user-images.githubusercontent.com/817508/100672192-dd258500-3361-11eb-845f-e8b5109752e4.png)

[![PHP Version](https://camo.githubusercontent.com/6e9ffc23b6f562594a7bd1115e3ef93498cac832aba34585a4b4988c9e9f449e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7a6f6f6e2f707570687065746565722e7376673f7374796c653d666c61742d737175617265)](http://php.net/)[![Composer Version](https://camo.githubusercontent.com/c5127ecddc938cf0155b5adcc37598d4c3f8ea2fd5041e2a7d515c40b869f645/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7a6f6f6e2f707570687065746565722e7376673f7374796c653d666c61742d737175617265266c6162656c3d436f6d706f736572)](https://packagist.org/packages/zoon/puphpeteer)[![Node Version](https://camo.githubusercontent.com/0bfd5ec7bc36bba4678cb47fd36c8a9527c4e75d77e1de8de7a58deb072e32ed/68747470733a2f2f696d672e736869656c64732e696f2f6e6f64652f762f407a6f6f6e2f707570687065746565722e7376673f7374796c653d666c61742d737175617265266c6162656c3d4e6f6465)](https://nodejs.org/)[![NPM Version](https://camo.githubusercontent.com/19cda64fd88dc91390c25fa4d75ea42ae7095eff9aaaf7534e6f96d86a75d97a/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f762f407a6f6f6e2f707570687065746565722e7376673f7374796c653d666c61742d737175617265266c6162656c3d4e504d)](https://www.npmjs.com/package/@nesk/puphpeteer)[![Build Status](https://camo.githubusercontent.com/226d417219825eab4e3d15f591409043b5844e0bc9180018db8f8277ec9339d8/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f7a6f6f6e2f707570687065746565722e7376673f7374796c653d666c61742d737175617265266c6162656c3d4275696c64253230537461747573)](https://travis-ci.org/nesk/puphpeteer)

A [Puppeteer](https://github.com/GoogleChrome/puppeteer/) bridge for PHP, supporting the entire API. Based on [Rialto](https://github.com/zoonru/rialto/), a package to manage Node resources from PHP.

Here are some examples [borrowed from Puppeteer's documentation](https://github.com/GoogleChrome/puppeteer/blob/master/README.md#usage) and adapted to PHP's syntax:

**Example** - navigating to  and saving a screenshot as *example.png*:

```
use Nesk\Puphpeteer\Puppeteer;

$puppeteer = new Puppeteer;
$browser = $puppeteer->launch();

$page = $browser->newPage();
$page->goto('https://example.com');
$page->screenshot(['path' => 'example.png']);

$browser->close();
```

**Example** - evaluate a script in the context of the page:

```
use Nesk\Puphpeteer\Puppeteer;
use Nesk\Rialto\Data\JsFunction;

$puppeteer = new Puppeteer;

$browser = $puppeteer->launch();
$page = $browser->newPage();
$page->goto('https://example.com');

// Get the "viewport" of the page, as reported by the page.
$dimensions = $page->evaluate(JsFunction::createWithBody("
    return {
        width: document.documentElement.clientWidth,
        height: document.documentElement.clientHeight,
        deviceScaleFactor: window.devicePixelRatio
    };
"));

printf('Dimensions: %s', print_r($dimensions, true));

$browser->close();
```

Requirements and installation
-----------------------------

[](#requirements-and-installation)

This package requires PHP &gt;= 7.3 and Node &gt;= 8.

Install it with these two command lines:

```
composer require zoon/puphpeteer
npm install github:zoonru/puphpeteer
```

Notable differences between PuPHPeteer and Puppeteer
----------------------------------------------------

[](#notable-differences-between-puphpeteer-and-puppeteer)

### Puppeteer's class must be instantiated

[](#puppeteers-class-must-be-instantiated)

Instead of requiring Puppeteer:

```
const puppeteer = require('puppeteer');
```

You have to instantiate the `Puppeteer` class:

```
$puppeteer = new Puppeteer;
```

This will create a new Node process controlled by PHP.

You can also pass some options to the constructor, see [Rialto's documentation](https://github.com/nesk/rialto/blob/master/docs/api.md#options). PuPHPeteer also extends these options:

```
[
    // Logs the output of Browser's console methods (console.log, console.debug, etc...) to the PHP logger
    'log_browser_console' => false,
]
```

**⏱ Want to use some timeouts higher than 30 seconds in Puppeteer's API?**
If you use some timeouts higher than 30 seconds, you will have to set a higher value for the `read_timeout` option (default: `35`):

```
$puppeteer = new Puppeteer([
    'read_timeout' => 65, // In seconds
]);

$puppeteer->launch()->newPage()->goto($url, [
    'timeout' => 60000, // In milliseconds
]);
```

### No need to use the `await` keyword

[](#no-need-to-use-the-await-keyword)

With PuPHPeteer, every method call or property getting/setting is synchronous.

### Some methods have been aliased

[](#some-methods-have-been-aliased)

The following methods have been aliased because PHP doesn't support the `$` character in method names:

- `$` =&gt; `querySelector`
- `$$` =&gt; `querySelectorAll`
- `$x` =&gt; `querySelectorXPath`
- `$eval` =&gt; `querySelectorEval`
- `$$eval` =&gt; `querySelectorAllEval`

Use these aliases just like you would have used the original methods:

```
$divs = $page->querySelectorAll('div');
```

### Evaluated functions must be created with `JsFunction`

[](#evaluated-functions-must-be-created-with-jsfunction)

Functions evaluated in the context of the page must be written [with the `JsFunction` class](https://github.com/nesk/rialto/blob/master/docs/api.md#javascript-functions), the body of these functions must be written in JavaScript instead of PHP.

```
use Nesk\Rialto\Data\JsFunction;

$pageFunction = JsFunction::createWithParameters(['element'])
    ->body("return element.textContent");
```

### Exceptions must be caught with `->tryCatch`

[](#exceptions-must-be-caught-with--trycatch)

If an error occurs in Node, a `Node\FatalException` will be thrown and the process closed, you will have to create a new instance of `Puppeteer`.

To avoid that, you can ask Node to catch these errors by prepending your instruction with `->tryCatch`:

```
use Nesk\Rialto\Exceptions\Node;

try {
    $page->tryCatch->goto('invalid_url');
} catch (Node\Exception $exception) {
    // Handle the exception...
}
```

Instead, a `Node\Exception` will be thrown, the Node process will stay alive and usable.

### Puppeteer plugins

[](#puppeteer-plugins)

To use puppeteer-extra plugins add them to your project:

```
npm install puppeteer puppeteer-extra puppeteer-extra-plugin-stealth
```

Then override js inclusion with js\_extra option

```
    $puppeteer = new Puppeteer([
        'js_extra' => /** @lang JavaScript */ "
            const puppeteer = require('puppeteer-extra');
            const StealthPlugin = require('puppeteer-extra-plugin-stealth');
            puppeteer.use(StealthPlugin());
            instruction.setDefaultResource(puppeteer);
        "
    ]);
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

Logo attribution
----------------

[](#logo-attribution)

PuPHPeteer's logo is composed of:

- [Puppet](https://thenounproject.com/search/?q=puppet&i=52120) by Luis Prado from [the Noun Project](http://thenounproject.com/).
- [Elephant](https://thenounproject.com/search/?q=elephant&i=954119) by Lluisa Iborra from [the Noun Project](http://thenounproject.com/).

Thanks to [Laravel News](https://laravel-news.com/) for picking the icons and colors of the logo.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 78.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

856d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f52d05964e959a0303a2759bbd557b6d21c2938393cfe3bce940ef52856230b5?d=identicon)[systema.working](/maintainers/systema.working)

---

Top Contributors

[![nesk](https://avatars.githubusercontent.com/u/817508?v=4)](https://github.com/nesk "nesk (107 commits)")[![xtrime-ru](https://avatars.githubusercontent.com/u/34161928?v=4)](https://github.com/xtrime-ru "xtrime-ru (11 commits)")[![spekulatius](https://avatars.githubusercontent.com/u/8433587?v=4)](https://github.com/spekulatius "spekulatius (8 commits)")[![RobinDev](https://avatars.githubusercontent.com/u/3944894?v=4)](https://github.com/RobinDev "RobinDev (5 commits)")[![erikgaal](https://avatars.githubusercontent.com/u/1234268?v=4)](https://github.com/erikgaal "erikgaal (2 commits)")[![systemaworking](https://avatars.githubusercontent.com/u/69110904?v=4)](https://github.com/systemaworking "systemaworking (2 commits)")[![nickescobedo](https://avatars.githubusercontent.com/u/2837169?v=4)](https://github.com/nickescobedo "nickescobedo (1 commits)")[![SirLouen](https://avatars.githubusercontent.com/u/224787?v=4)](https://github.com/SirLouen "SirLouen (1 commits)")

---

Tags

phptestingwebautomationpuppeteerdeveloper-toolsheadless-chrome

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/systemaworking-puphpeteer/health.svg)

```
[![Health](https://phpackages.com/badges/systemaworking-puphpeteer/health.svg)](https://phpackages.com/packages/systemaworking-puphpeteer)
```

###  Alternatives

[zoon/puphpeteer

A Puppeteer bridge for PHP, supporting the entire API.

204192.9k1](/packages/zoon-puphpeteer)[infection/infection

Infection is a Mutation Testing framework for PHP. The mutation adequacy score can be used to measure the effectiveness of a test set in terms of its ability to detect faults.

2.2k26.2M1.8k](/packages/infection-infection)[phan/phan

A static analyzer for PHP

5.6k11.2M1.1k](/packages/phan-phan)[playwright-php/playwright

Modern PHP library for Playwright automation: browsing, scraping, screenshots, testing, and more.

7613.0k5](/packages/playwright-php-playwright)[nigelcunningham/puphpeteer

A Puppeteer bridge for PHP, supporting the entire API.

2221.7k](/packages/nigelcunningham-puphpeteer)[victor-teles/playwright-php

A Playwright bridge for PHP.

203.6k](/packages/victor-teles-playwright-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
