PHPackages                             denis-kisel/casper-curl - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. denis-kisel/casper-curl

ActiveLibrary[HTTP &amp; Networking](/categories/http)

denis-kisel/casper-curl
=======================

A phantomjsCURL for get content of difficult sites

v0.2.4(6y ago)236MITPHPPHP &gt;=7.2

Since Oct 21Pushed 6y ago1 watchersCompare

[ Source](https://github.com/denis-kisel/php-casper-curl)[ Packagist](https://packagist.org/packages/denis-kisel/casper-curl)[ Docs](https://github.com/denis-kisel/php-casper-curl)[ RSS](/packages/denis-kisel-casper-curl/feed)WikiDiscussions master Synced today

READMEChangelog (6)Dependencies (1)Versions (7)Used By (0)

Casper CURL
===========

[](#casper-curl)

Basics on [casperjs](https://casperjs.org/) / [phantomjs](https://phantomjs.org/) libs for get content difficult sites.

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

[](#installation)

1 Install global casperjs and phantomjs

```
npm install -g casperjs
npm install -g phantomjs

# If phantomjs is running with errors
npm install -g phantomjs --ignore-scripts
```

2 Install CasperCURL package

```
composer require denis-kisel/casper-curl
```

### Publish Configuration File(If Use Laravel)

[](#publish-configuration-fileif-use-laravel)

If you use another framework or native PHP, just skip this setting.

```
php artisan vendor:publish --provider="DenisKisel\CasperCURL\ServiceProvider" --tag="config"
```

Usage
-----

[](#usage)

Simple example

```
//Return content page
$casperCURL = new \DenisKisel\CasperCURL\CasperCURL($storageDir);
$response = $casperCURL->to('https://google.com')->request()
```

### Set Method

[](#set-method)

method($method)
Methods available: `GET|POST|PUT|DELETE`
By default use `GET`

```
$casperCURL = new \DenisKisel\CasperCURL\CasperCURL($storageDir);
$response = $casperCURL->to('https://google.com')
    ->method('POST')
    ->request()
```

### Set Data

[](#set-data)

withData($arrayData)

```
$casperCURL = new \DenisKisel\CasperCURL\CasperCURL($storageDir);
$response = $casperCURL->to('https://google.com')
    ->withData([
        'login' => '***',
        'pass' => '***'
    ])
    ->method('POST')
    ->request()
```

### Set Headers

[](#set-headers)

withHeaders($arrayHeaders)

```
$casperCURL = new \DenisKisel\CasperCURL\CasperCURL($storageDir);
$response = $casperCURL->to('https://google.com')
    ->withHeaders([
        'User-Agent' => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:26.0) Gecko/20100101 Firefox/26.0',
        'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'
    ])
    ->request()
```

### Set UserAgent

[](#set-useragent)

userAgent($userAgent)
By default use: Mozilla/5.0 (Windows NT 10.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36

```
$casperCURL = new \DenisKisel\CasperCURL\CasperCURL($storageDir);
$response = $casperCURL->to('https://google.com')
    ->userAgent('Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:26.0) Gecko/20100101 Firefox/26.0')
    ->request()
```

### Use Proxy

[](#use-proxy)

withProxy($ip, $port \[, $method = 'http'\] \[, $login = null\] \[, $pass = null\])

Methods available: `http|socks5|none`

```
$casperCURL = new \DenisKisel\CasperCURL\CasperCURL($storageDir);
$response = $casperCURL->to('https://google.com')
    ->withProxy($ip, $port)
    ->request()
```

### Use Cookies

[](#use-cookies)

withCookie($fileName, \[, $dir\])
By default cookie is `disabled`.
By default cookies file is stored in storage dir.

```
$casperCURL = new \DenisKisel\CasperCURL\CasperCURL($storageDir);
$response = $casperCURL->to('https://google.com')
    ->withCookie('cookie.txt')
    ->request()
```

### Use WindowSize(ViewPort)

[](#use-windowsizeviewport)

windowSize($with, $height)
By default: width/height: `1920/1080` px

```
$casperCURL = new \DenisKisel\CasperCURL\CasperCURL($storageDir);
$response = $casperCURL->to('https://google.com')
    ->windowSize(320, 600)
    ->request()
```

### Phantom Cli Options

[](#phantom-cli-options)

Set custom phantom cli options
List of available options: [Phantom Options Doc](https://phantomjs.org/api/command-line.html)

withPhantomOptions($arrayOptions)
Key of option `must not contain` a prefix `--`

```
$options = [
    'debug' => 'true',
    'ignore-ssl-errors' => 'true'
];

$casperCURL = new \DenisKisel\CasperCURL\CasperCURL($storageDir);
$response = $casperCURL->to('https://google.com')
    ->withPhantomOptions($options)
    ->request()
```

CasperJS
--------

[](#casperjs)

For use dynamic handling content
[Casper Doc](http://casperjs.org/)

### Use Casper Then

[](#use-casper-then)

casperThen($jsScript)
[DOC](http://docs.casperjs.org/en/latest/modules/casper.html#then)

```
$casperCURL = new \DenisKisel\CasperCURL\CasperCURL($storageDir);
$response = $casperCURL->to('http://google.fr')
    ->casperThen('
         this.fill('form[action="/search"]', { q: 'casperjs' }, true);
         this.wait(2000, function () {
             this.capture('step_1.png');
         });

    ')
    ->request()
```

### Use Custom Casper JS

[](#use-custom-casper-js)

Custom casper body js
[DOC](http://docs.casperjs.org/en/1.1-beta2/index.html)

```
$casperCURL = new \DenisKisel\CasperCURL\CasperCURL($storageDir);
$response = $casperCURL->to('http://google.fr')
    ->customCasper('
        casper.then(function() {
             this.fill('form[action="/search"]', { q: 'casperjs' }, true);
             this.wait(2000, function () {
                 this.capture('step_1.png');
             });
        });
    ')
    ->request()
```

Debug
-----

[](#debug)

enableDebug()
Will be store response data and capture in storage dir

```
$casperCURL = new \DenisKisel\CasperCURL\CasperCURL($storageDir);
$response = $casperCURL->to('http://google.com')
    ->enableDebug()
    ->request()
```

Response
--------

[](#response)

Response is object with fields:

- status (exp. 200|404|500)
- content (string html|dom|txt)

```
$casperCURL = new \DenisKisel\CasperCURL\CasperCURL($storageDir);
$response = $casperCURL->to('http://google.com')
    ->request();

$response->status;
$response->content;
```

### Response Content

[](#response-content)

By default request response full page content
[DOC](http://docs.casperjs.org/en/latest/modules/casper.html#getpagecontent)

But response can override by `output` variable

```
$casperCURL = new \DenisKisel\CasperCURL\CasperCURL($storageDir);
$response = $casperCURL->to('http://google.fr')
    ->casperThen('
         this.fill('form[action="/search"]', { q: 'casperjs' }, true);
         this.wait(2000, function () {
             this.capture('step_1.png');
         });

         output = console.log('Override default output!');
    ')
    ->request()
```

Use In Laravel
--------------

[](#use-in-laravel)

```
$response = \DenisKisel\CasperCURL\LCasperCURL::to('https://google.com')->request()
```

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT)

Contact
-------

[](#contact)

Developer: Denis Kisel

- Email:
- Skype: live:denis.kisel92

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

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.

###  Release Activity

Cadence

Every ~3 days

Total

6

Last Release

2375d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/76b9b00b6d5b5f8de8f20a5e39e9e4a6caef51a637ad8a047787a6442b9278ef?d=identicon)[denis-kisel](/maintainers/denis-kisel)

---

Top Contributors

[![den-is-ua](https://avatars.githubusercontent.com/u/235117855?v=4)](https://github.com/den-is-ua "den-is-ua (27 commits)")

---

Tags

casperjscurllaravelphantomjsphpphplaravelcurlphantomjscasperJs

### Embed Badge

![Health badge](/badges/denis-kisel-casper-curl/health.svg)

```
[![Health](https://phpackages.com/badges/denis-kisel-casper-curl/health.svg)](https://phpackages.com/packages/denis-kisel-casper-curl)
```

###  Alternatives

[stefangabos/zebra_curl

A high performance solution for making multiple HTTP requests concurrently, asynchronously from your PHP projects using cURL

21971.3k2](/packages/stefangabos-zebra-curl)[vinelab/http

An http library developed for the laravel framework. aliases itself as HttpClient

59300.2k11](/packages/vinelab-http)[basement-chat/basement-chat

Add a real-time chat widget to your Laravel application.

4983.9k](/packages/basement-chat-basement-chat)[unikent/curl

Laravel Curl Helper Library.

1442.4k](/packages/unikent-curl)

PHPackages © 2026

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