PHPackages                             phantomphp/phantomphp - 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. phantomphp/phantomphp

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

phantomphp/phantomphp
=====================

Seamless management and comunication with phantomjs process from php

19.5kPHP

Since Oct 17Pushed 9y ago1 watchersCompare

[ Source](https://github.com/gsouf/phantomphp)[ Packagist](https://packagist.org/packages/phantomphp/phantomphp)[ RSS](/packages/phantomphp-phantomphp/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

PhantomPhp
==========

[](#phantomphp)

**WIP** - This project is under heavy development you can use it now, but be aware that everything can change at anytime.

The project
-----------

[](#the-project)

Start a phantomjs process and control it from php. The top feature is the ability to communicate with a single phantomjs script from many php scripts.

Note: The project is NOT tested on windows and thus it might work only on unix systems

Overview
--------

[](#overview)

```
use PhantomPhp\PhantomClient;
use PhantomPhp\PageManager;

// Create a phantom client that is responsible for managing phantomjs process
$client = new PhantomClient();
// Start the phantomjs js process
$client->start();

// Page manager helps to generate page (like a browser with pages/tabs)
$pageManager = new PageManager($client);

// Create a new page
$page = $pageManager->createPage();
// Open an url on this page
$page->navigate('http://example.com');

// Get the dom
$domString = $page->getDomContent();

// Run custom javascript on the page
$divWidth = $page->runScript('return document.getElementsByTagName("div")[0].offsetWidth;');

// Stop the phantomjs process
$client->stop();
```

Page API
--------

[](#page-api)

TODO: page api doc

Multi process communication
---------------------------

[](#multi-process-communication)

### Communication Channel

[](#communication-channel)

PhnatomPhp supports different communication channel. A communication channel represents a way to communicate with the underlying phantomjs process. By default php and phantomjs communicate through pipes, but you can turn phantomjs in a real application waiting for any script to interact with it.

To do this just start a HttpClient with a given port and you are ready to play with:

```
use PhantomPhp\HttpClient;
use PhantomPhp\PageManager;

$client = new HttpClient(8080);
$client->start();
// Now phantomjs is listening on port 8080

// As with the stream client you can start a pageManager based uppon this http client
$pageManager = new PageManager($client);
// Create a page named foo
$page = $pageManager->createPage('foo');
$page->navigate('http://example.com');

// ....
```

If you leave this previous process opened and open another process, the other process is able to call phantomjs without starting a new client. To do this you just have to define a http channel for the same port:

```
use PhantomPhp\Communication\HttpRequest;
use PhantomPhp\PageManager;

$channel = new HttpRequest(8080);

// and pass this channel to a new page manager
$pageManager = new PageManager($client);
// Get the page named foo created on the other process
$page = $pageManager->getPage('foo');  // warning: getPage is not implemented yet
$dom = $page->getDomContent();

// ....
```

Roadmap
-------

[](#roadmap)

- More end points for page api
- make the page high level synchronizable on demand (also on `$page->navigate` to lower request count)
- Support PSR-7 request
- Support page cookies, proxy, viewport, ua, etc...
- Support default proxy, defualt ua, default viewport, etc...
- Test error
- File log

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 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/e6f24737cd0c46fea5e7a294f91582b35a052ce23cd2375f8f48e2faecb6fd78?d=identicon)[gsouf](/maintainers/gsouf)

---

Top Contributors

[![gsouf](https://avatars.githubusercontent.com/u/3215399?v=4)](https://github.com/gsouf "gsouf (29 commits)")

### Embed Badge

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

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

###  Alternatives

[gamez/typed-collection

Type-safe collections based on Laravel Collections

45317.8k](/packages/gamez-typed-collection)

PHPackages © 2026

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