PHPackages                             workdigital/casperjs-php-driver - 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. workdigital/casperjs-php-driver

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

workdigital/casperjs-php-driver
===============================

An improved general purpose PHP driver for CasperJS

1.1.5(8y ago)214.9k[1 issues](https://github.com/DiceHoldingsInc/casperjs-php-driver/issues)PHPPHP &gt;=5.4

Since Aug 9Pushed 8y ago25 watchersCompare

[ Source](https://github.com/DiceHoldingsInc/casperjs-php-driver)[ Packagist](https://packagist.org/packages/workdigital/casperjs-php-driver)[ RSS](/packages/workdigital-casperjs-php-driver/feed)WikiDiscussions master Synced today

READMEChangelog (9)Dependencies (1)Versions (10)Used By (0)

CasperJS PHP Driver
===================

[](#casperjs-php-driver)

[![Build status](https://camo.githubusercontent.com/cbda82a7d440f75cb74b0664e2a421911a27e2fc809c0d33405a9ca6c84ae0ee/68747470733a2f2f7472617669732d63692e6f72672f44696365486f6c64696e6773496e632f6361737065726a732d7068702d6472697665722e7376673f6272616e63683d6d6173746572)](https://camo.githubusercontent.com/cbda82a7d440f75cb74b0664e2a421911a27e2fc809c0d33405a9ca6c84ae0ee/68747470733a2f2f7472617669732d63692e6f72672f44696365486f6c64696e6773496e632f6361737065726a732d7068702d6472697665722e7376673f6272616e63683d6d6173746572)

Prerequisites
-------------

[](#prerequisites)

This driver will assume that the command `casperjs` is available in your `$PATH`. If not, you can install it with:

```
npm install -g casperjs

```

Installation
------------

[](#installation)

You can use this package in your project via composer. Add these lines to your `composer.json`:

```
"require": {
  "workdigital/casperjs-php-driver": "1.*"
},
…

```

Latest stable release is 1.0

Examples
--------

[](#examples)

### Basic usage

[](#basic-usage)

```
$driver = new CasperJs\Driver();
$output = $driver->start('http://someurl.com')
                 ->run();
```

### Setting request parameters and interacting with the page

[](#setting-request-parameters-and-interacting-with-the-page)

The entire point of using a tool like Casper is to be able to properly interact with the DOM for both testing and scraping purposes. This driver tries to expose a friendly interface to do so where you can define both request params and DOM interaction before making the actual call.

```
$driver = new CasperJs\Driver();
$driver->start('http://someurl.com')
       ->setUserAgent('AmericanPizzaiolo')
       ->setHeaders([
           'Accept-Language' => ['en-US'],
           'Some-Header' => 'Foo-bar',
       ])
       ->evaluate('make me a pizza')
       ->setViewPort(1024, 768)
       ->waitForSelector('.selector', 30000)
       ->wait(10000)
       ->click('.selector');

$output = $driver->run();
```

### Using a proxy for your call

[](#using-a-proxy-for-your-call)

```
$driver = new CasperJs\Driver();
$driver->start('http://someurl.com')
       ->useProxy('1.1.1.1');

$output = $driver->run();
```

Getting the Casper Output
-------------------------

[](#getting-the-casper-output)

Whenever you execute `Driver::run()` the `Driver` will return an `Output` object that will encapsulate the Casper output. `Output` will expose the captured casper data or throw an exception in case the desired behaviour wasn't performed (i.e. if a css selector to be present in the page after timeout expired).

### Extracting Data

[](#extracting-data)

```
$html = $output->getHtml();
$statusCode = $output->getStatusCode();
$currentUrl = $output->getCurrentUrl();
```

More examples
-------------

[](#more-examples)

For more examples check out `test/DriverTest.php`

Credits
-------

[](#credits)

This driver is essentially an enhanced and improved version of [the original alwex/php-casperjs](https://github.com/alwex/php-casperjs).

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

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

Every ~97 days

Recently: every ~113 days

Total

9

Last Release

3200d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8de844f34877c39b41ee5ad0c36f163db98bf29f55e7bc8c15ebcec3e2452715?d=identicon)[jnardiello](/maintainers/jnardiello)

![](https://www.gravatar.com/avatar/e40a2354a9670f4728abac4a002635e4e6efcca194e60eef0ad357042ba17409?d=identicon)[fguery](/maintainers/fguery)

---

Top Contributors

[![fguery](https://avatars.githubusercontent.com/u/334385?v=4)](https://github.com/fguery "fguery (19 commits)")[![jnardiello](https://avatars.githubusercontent.com/u/657293?v=4)](https://github.com/jnardiello "jnardiello (3 commits)")[![Putzy](https://avatars.githubusercontent.com/u/2552799?v=4)](https://github.com/Putzy "Putzy (2 commits)")[![ArlingtonHouse](https://avatars.githubusercontent.com/u/762607?v=4)](https://github.com/ArlingtonHouse "ArlingtonHouse (1 commits)")

---

Tags

workdigital-keep

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/workdigital-casperjs-php-driver/health.svg)

```
[![Health](https://phpackages.com/badges/workdigital-casperjs-php-driver/health.svg)](https://phpackages.com/packages/workdigital-casperjs-php-driver)
```

###  Alternatives

[kylekatarnls/carbonite

Freeze, accelerate, slow down time and many more with Carbon.

23301.9k1](/packages/kylekatarnls-carbonite)[elegantly/laravel-cookies-consent

Cookie consent for Laravel

254.6k](/packages/elegantly-laravel-cookies-consent)

PHPackages © 2026

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