2017 © Pedro Peláez
 

library chrome-devtools-protocol

Chrome Devtools Protocol client for PHP

image

jakubkulhan/chrome-devtools-protocol

Chrome Devtools Protocol client for PHP

  • Sunday, July 29, 2018
  • by jakubkulhan
  • Repository
  • 5 Watchers
  • 35 Stars
  • 884 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 10 Forks
  • 3 Open issues
  • 14 Versions
  • 125 % Grown

The README.md

Chrome Devtools Protocol PHP client

Build Latest Stable Version License, (*1)

PHP client for Chrome Devtools Protocol., (*2)

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., (*3)

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

$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();
}

Using an already running Chrome browser

use ChromeDevtoolsProtocol\Instance\Instance;

$instance = new Instance(/* host: */ "localhost", /* port: */ 9222);


$ctx = Context::withTimeout(Context::background(), 30 /* seconds */);

$tab = $instance->open($ctx);
$tab->activate($ctx);

$devtools = $tab->devtools();

// ...work with devtools

// no need to call ->close() as no new process is started

License

Licensed under MIT license. See LICENSE file., (*5)

The Versions

29/07 2018

dev-master

9999999-dev

Chrome Devtools Protocol client for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

web automation chrome chrome-devtools chrome-devtools-protocol headless-chrome

31/03 2018

v1.0.0

1.0.0.0

Chrome Devtools Protocol client for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

web automation chrome chrome-devtools chrome-devtools-protocol headless-chrome

08/03 2018

v0.4.0

0.4.0.0

Chrome Devtools Protocol client for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

web automation chrome chrome-devtools chrome-devtools-protocol headless-chrome

02/02 2018

v0.3.1

0.3.1.0

Chrome Devtools Protocol client for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

web automation chrome chrome-devtools chrome-devtools-protocol headless-chrome

23/01 2018

v0.3.0

0.3.0.0

Chrome Devtools Protocol client for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

web automation chrome chrome-devtools chrome-devtools-protocol headless-chrome

11/12 2017

v0.2.6

0.2.6.0

Chrome Devtools Protocol client for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

web automation chrome chrome-devtools chrome-devtools-protocol headless-chrome

30/11 2017

v0.2.5

0.2.5.0

Chrome Devtools Protocol client for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

web automation chrome chrome-devtools chrome-devtools-protocol headless-chrome

24/11 2017

v0.2.4

0.2.4.0

Chrome Devtools Protocol client for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

web automation chrome chrome-devtools chrome-devtools-protocol headless-chrome

24/11 2017

v0.2.3

0.2.3.0

Chrome Devtools Protocol client for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

web automation chrome chrome-devtools chrome-devtools-protocol headless-chrome

23/11 2017

v0.2.2

0.2.2.0

Chrome Devtools Protocol client for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

web automation chrome chrome-devtools chrome-devtools-protocol headless-chrome

23/11 2017

v0.2.1

0.2.1.0

Chrome Devtools Protocol client for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

web automation chrome chrome-devtools chrome-devtools-protocol headless-chrome

23/11 2017

v0.2.0

0.2.0.0

Chrome Devtools Protocol client for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

web automation chrome chrome-devtools chrome-devtools-protocol headless-chrome

22/11 2017

v0.1.1

0.1.1.0

Chrome Devtools Protocol client for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

web automation chrome chrome-devtools chrome-devtools-protocol headless-chrome

22/11 2017

v0.1.0

0.1.0.0

Chrome Devtools Protocol client for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

web automation chrome chrome-devtools chrome-devtools-protocol headless-chrome