• Stars
    star
    166
  • Rank 220,588 (Top 5 %)
  • Language
    PHP
  • License
    MIT License
  • Created over 6 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Chrome Devtools Protocol client for PHP

Chrome Devtools Protocol PHP client

Build Latest Stable Version License

PHP client for Chrome Devtools Protocol.

Basic usage

// context creates deadline for operations
$ctx = Context::withTimeout(Context::background(), 30 /* seconds */);

// launcher starts chrome process ($instance)
$launcher = new Launcher();
$instance = $launcher->launch($ctx);

try {
	// work with new tab
	$tab = $instance->open($ctx);
	$tab->activate($ctx);

	$devtools = $tab->devtools();
	try {
		$devtools->page()->enable($ctx);
		$devtools->page()->navigate($ctx, NavigateRequest::builder()->setUrl("https://www.google.com/")->build());
		$devtools->page()->awaitLoadEventFired($ctx);

		// ... work with page ...
		// e.g.
		// - print to PDF: $devtools->page()->printToPDF($ctx, PrintToPDFRequest::make());
		// - capture screenshot: $devtools->page()->captureScreenshot($ctx, CaptureScreenshotRequest::builder()->setFormat("jpg")->setQuality(95)->build());

	} finally {
		// devtools client needs to be closed
		$devtools->close();
	}

} finally {
	// process needs to be killed
	$instance->close();
}

Headless Chrome isolated contexts

Headless Chrome supports feature called browser contexts - they're like incognito windows - cookies, local storage etc. are not shared. After browser context is destroyed, user data created in given context, are destroyed.

Unlike incognito windows, there can be multiple isolate browser contexts at the same time.

$ctx = Context::withTimeout(Context::background(), 10);
$launcher = new Launcher();
$instance = $launcher->launch($ctx);
try {
	$session = $instance->createSession($ctx);
	try {

		// $session implements DevtoolsClientInterface, same as returned from Tab::devtools()

	} finally {
		$session->close();
	}
} finally {
	$instance->close();
}

License

Licensed under MIT license. See LICENSE file.

More Repositories

1

bunny

Performant pure-PHP AMQP (RabbitMQ) sync/async (ReactPHP) library
PHP
676
star
2

ingress-merge

Merge Ingress Controller for Kubernetes
Go
140
star
3

btree

Append-only B+Tree implemented purely in PHP.
PHP
75
star
4

hit-server-bench

[ABANDONED] Comparison of many HTTP servers raw hit performance
Java
69
star
5

js2php

Javascript parser, compiler and interpreter written in PHP
PHP
49
star
6

couchdb-php

Simple PHP API to CouchDB
PHP
26
star
7

pacc

[OLD] use PHP7 rewrite https://github.com/axmachado/pacc (orig. description: pacc (PHP yACC), parser generator for PHP)
PHP
19
star
8

shopaholic

Shopaholic is an open-source e-shop based on PHP with Nette Framework and dibi under the hood.
PHP
18
star
9

reactphp-symfony

ReactPHP + Symfony example
PHP
14
star
10

phpeg

PEG for PHP
PHP
10
star
11

jeph

Application framework that runs Javascript on top of regular PHP engine
PHP
8
star
12

xo

Real-time multiplayer five-in-a-row Facebook game
JavaScript
7
star
13

fcgipass

Proxy HTTP requests to FastCGI server
Go
6
star
14

kube-jessie-ansible

[ABANDONED] Kubernetes set-up on Debian Jessie using Ansible
5
star
15

benchmarks

Some PHP benchmarks.
PHP
5
star
16

react-fcgi

[EXPERIMENTAL] Asynchronous FastCGI server built on ReactPHP
PHP
4
star
17

metatable

[ABANDONED] Simple way how to store and retrieve data, written natively in PHP.
PHP
3
star
18

bleve-additions

Some useful tools for Bleve
Go
3
star
19

nette-coffee

Nette Framework application where Presenters are generated from Coffeescript source
PHP
2
star
20

pssh

SSH server for any environment where PHP is
PHP
2
star
21

d4node

school project - simple UDP messaging with (sort of) auto-discovery
C
2
star
22

sally

Javascript library, which emulates some "advanced" CSS selectors (+, >, [attr]) for Microsoft Internet Explorer 6 using Sizzle selector library.
JavaScript
1
star
23

cc16-java-aop-multithreading

Codecamp 2016 AOP/multithreading lecture
Java
1
star
24

go-workshop

Go
1
star
25

guestbook

Guestbook using PHP and metatable
PHP
1
star
26

sandbox

Puts given program into sandbox.
C
1
star
27

cc16-java-elasticsearch

Codecamp 2016 Java Elasticsearch lecture
Java
1
star
28

nbh

neighbour discovery server
Erlang
1
star
29

xsession

xsession script that rewrites home on every X login
1
star
30

bayesian-spam-filter

Bayesian spam filter in Python
Python
1
star
31

dockerfiles

Custom Dockerfiles based on Debian Stretch.
Dockerfile
1
star