PHPackages                             cursestaff/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. cursestaff/puphpeteer

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

cursestaff/puphpeteer
=====================

A Puppeteer bridge for PHP, supporting the entire API.

00PHP

Since Nov 14Pushed 3y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)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/7f189bbbfc66eb35e1c57ba653d0910cdcf7f01f966a713ee1e2d3171cf1a482/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6e65736b2f707570687065746565722e7376673f7374796c653d666c61742d737175617265)](http://php.net/)[![Composer Version](https://camo.githubusercontent.com/7d50b43d342d7d30bc16b787072dab09786e8bba30073370b3b460c1d65cc3da/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e65736b2f707570687065746565722e7376673f7374796c653d666c61742d737175617265266c6162656c3d436f6d706f736572)](https://packagist.org/packages/nesk/puphpeteer)[![Node Version](https://camo.githubusercontent.com/8fa99a42a9d6e42003dc07828812dde4b2142964305f01f801eb81655679fa40/68747470733a2f2f696d672e736869656c64732e696f2f6e6f64652f762f406e65736b2f707570687065746565722e7376673f7374796c653d666c61742d737175617265266c6162656c3d4e6f6465)](https://nodejs.org/)[![NPM Version](https://camo.githubusercontent.com/d169754edb021953eee24b67507962711b06d8306ef79ec96973605f289bcb66/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f762f406e65736b2f707570687065746565722e7376673f7374796c653d666c61742d737175617265266c6162656c3d4e504d)](https://www.npmjs.com/package/@nesk/puphpeteer)[![Build Status](https://camo.githubusercontent.com/fde58d10e748081ab14d2e094e73781de13d90c9d1e347912f0c270fb7f2de4c/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6e65736b2f707570687065746565722e7376673f7374796c653d666c61742d737175617265266c6162656c3d4275696c64253230537461747573)](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/nesk/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 nesk/puphpeteer
npm install @nesk/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

13

—

LowBetter than 1% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity24

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/28d29549f7e1ab84a6e34360d9696fce811f3d6ed41c6f147972b525f193059a?d=identicon)[CurseStaff](/maintainers/CurseStaff)

---

Top Contributors

[![CurseStaff](https://avatars.githubusercontent.com/u/11999989?v=4)](https://github.com/CurseStaff "CurseStaff (3 commits)")

### Embed Badge

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

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

###  Alternatives

[symfony/polyfill-uuid

Symfony polyfill for uuid functions

688335.4M63](/packages/symfony-polyfill-uuid)[spatie/error-solutions

This is my package error-solutions

6853.2M11](/packages/spatie-error-solutions)[phpflo/phpflo

Flow-based programming for PHP

2173.3k4](/packages/phpflo-phpflo)[eftec/autoloadone

AutoloadOne is a program that generates an autoload class for PHP.

403.4k](/packages/eftec-autoloadone)[ys-tools/default-theme-configuration-bundle

OroCommerce Default Theme Configuration Bundle

124.2k](/packages/ys-tools-default-theme-configuration-bundle)

PHPackages © 2026

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