PHPackages                             milivojsa/chrome-php - 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. milivojsa/chrome-php

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

milivojsa/chrome-php
====================

A PHP Wrapper for Chrome Headless. Get the DOM of any webpage.

v3.0.2(7y ago)040031MITPHPPHP ^7.1

Since Apr 6Pushed 7y ago2 watchersCompare

[ Source](https://github.com/milivojsa/chrome-php)[ Packagist](https://packagist.org/packages/milivojsa/chrome-php)[ Docs](https://github.com/milivojsa/chrome-php)[ RSS](/packages/milivojsa-chrome-php/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (2)Dependencies (4)Versions (11)Used By (1)

A Chrome Headless wrapper for PHP
=================================

[](#a-chrome-headless-wrapper-for-php)

[![Version](https://camo.githubusercontent.com/cafd5145063c603e79f012ca9a55355e0fc507ee8baf976dcd647839888dbbba/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7461672f6d696c69766f6a73612f6368726f6d652d7068702e7376673f7374796c653d666c6174)](https://github.com/milivojsa/chrome-php) [![Build Status](https://camo.githubusercontent.com/05438e2434b188fe967517033f0c9e7d360c7d3f5974be7bd85652d17ca19875/68747470733a2f2f7472617669732d63692e6f72672f6d696c69766f6a73612f6368726f6d652d7068702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/milivojsa/chrome-php) [![StyleCI](https://camo.githubusercontent.com/364e2582fb9bac6d1eef86337406f620eff8d59d10a96cec643641a710204022/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3136383731343331302f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/168714310)

Get the DOM of any webpage by using headless Chrome. Inspired by [Browsershot](https://github.com/spatie/browsershot).

Requirements
------------

[](#requirements)

This package requires the [Puppeteer Chrome Headless Node library](https://github.com/GoogleChrome/puppeteer). If you want to install it on Ubuntu 16.04 you can do it like this:

```
sudo apt-get update
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
sudo npm install --global --unsafe-perm puppeteer
sudo chmod -R o+rx /usr/lib/node_modules/puppeteer/.local-chromium
```

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

[](#installation)

To add this package to your project, you can install it via composer by running

```
composer require milivojsa/chrome-php
```

Usage
-----

[](#usage)

Here is a quick example how to use this package:

```
use ChromeHeadless\ChromeHeadless;

$html = ChromeHeadless::url('https://example.com')->getHtml();
```

Instead of getting the DOM as a string, you can also use the`getDOMCrawler()` method, which will return a `Symfony\Component\DomCrawler\Crawler` instance.

```
use ChromeHeadless\ChromeHeadless;

$dom = ChromeHeadless::url('https://example.com')->getDOMCrawler();

$title = $dom->filter('title')->text();
```

This makes it easy to filter the DOM for specific elements. Check the full documentation [here](https://symfony.com/doc/current/components/dom_crawler.html).

### Timeout

[](#timeout)

You can specify a timeout after which the process will be killed. The timeout should be given in seconds.

```
ChromeHeadless::url('https://example.com')
                ->setTimeout(10)
                ->getDOMCrawler();
```

If the process runs out of time a `Symfony\Component\Process\Exception\ProcessTimedOutException` will be thrown.

### Custom Chrome Path

[](#custom-chrome-path)

You can specify a custom path to your Chrome installation.

```
ChromeHeadless::url('https://example.com')
                ->setChromePath('/path/to/chrome')
                ->getDOMCrawler();
```

### Custom User Agent

[](#custom-user-agent)

You can specify a custom user agent. By default the standard Chrome Headless user agent will be used.

```
ChromeHeadless::url('https://example.com')
                ->setUserAgent('nice-user-agent')
                ->getDOMCrawler();
```

### Custom Headers

[](#custom-headers)

You can specify custom headers which will be used for the request.

```
ChromeHeadless::url('https://example.com')
                ->setHeaders([
                    'DNT' => 1 // DO NOT TRACK
                ])
                ->getDOMCrawler();
```

### Blacklist

[](#blacklist)

You can specify a list of regular expressions for files that should not be loaded when you request a website. These expressions will be checked against the url of the file. Default behaviour of the method `setBlacklist(array $blacklist, $clean = false)` is to merge array passed as `$blacklist` with current `blacklist` property. If you want to override this default behaviour then you can set parameter `$clean` to be `true`.

```
ChromeHeadless::url('https://example.com')
                ->setBlacklist([
                    'www.example.com'
                ])
                ->setBlacklist([
                    'www.google-analytics.com',
                    'analytics.js'
                ]) // property blacklist now will have www.example.com and those two
                ->getDOMCrawler();
```

```
ChromeHeadless::url('https://example.com')
                ->setBlacklist([
                    'www.google-analytics.com',
                    'analytics.js'
                ])
                ->setBlacklist([
                    'www.example.com'
                ], true) // property blacklist now will only have www.example.com
                ->getDOMCrawler();
```

### Excluded

[](#excluded)

You can specify a list of resource types that should not be loaded when you request a website. These resource types will be checked against the resource type of the file. You can pass values: `document, stylesheet, image, media, font and script.` Default behaviour of the method `setExcluded(array $excluded, $clean = false)` is to merge array passed as `$excluded` with current `excluded` property. If you want to override this default behaviour then you can set parameter `$clean` to be `true`.

```
ChromeHeadless::url('https://example.com')
                ->setExcluded([
                    'document'
                ])
                ->setExcluded([
                    'stylesheet',
                    'image'
                ]) // property excluded now will only have document and those two
                ->getDOMCrawler();
```

```
ChromeHeadless::url('https://example.com')
                ->setExcluded([
                    'stylesheet'
                    'image'
                ])
                ->setExcluded([
                    'document'
                ], true) // property excluded now will only have only document
                ->getDOMCrawler();
```

### Viewport

[](#viewport)

You can specify a custom viewport that will be used when you make a request. By default the Chrome Headless standard of 800x600px will be used.

```
ChromeHeadless::url('https://example.com')
                ->setViewport([
                    'width' => 1920,
                    'height' => 1080
                ])
                ->getDOMCrawler();
```

Testing
-------

[](#testing)

You can run the tests by using

```
composer test
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 66.7% 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 ~47 days

Recently: every ~19 days

Total

9

Last Release

2584d ago

Major Versions

v1.2 → v2.02018-05-27

v2.2 → v3.0.02019-02-07

### Community

Maintainers

![](https://www.gravatar.com/avatar/96c1a25c968511365a6cb7eabe93c52048d59e817b951d36fa18488d826964a6?d=identicon)[milivojsa](/maintainers/milivojsa)

---

Top Contributors

[![milivojsa](https://avatars.githubusercontent.com/u/17594274?v=4)](https://github.com/milivojsa "milivojsa (16 commits)")[![helloiamlukas](https://avatars.githubusercontent.com/u/15997450?v=4)](https://github.com/helloiamlukas "helloiamlukas (6 commits)")[![torgheh](https://avatars.githubusercontent.com/u/14017891?v=4)](https://github.com/torgheh "torgheh (2 commits)")

---

Tags

domheadlesswebpagechrome

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/milivojsa-chrome-php/health.svg)

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

###  Alternatives

[spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

5.2k32.1M102](/packages/spatie-browsershot)[wa72/htmlpagedom

jQuery-inspired DOM manipulation extension for Symfony's Crawler

3383.9M34](/packages/wa72-htmlpagedom)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[luka-dev/headless-task-server-php

Helper for sending requests to luka-dev/headless-task-server

109.6k](/packages/luka-dev-headless-task-server-php)

PHPackages © 2026

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