{"id":13804720,"url":"https://github.com/jakubkulhan/chrome-devtools-protocol","last_synced_at":"2025-05-15T04:06:24.097Z","repository":{"id":26878005,"uuid":"111571114","full_name":"jakubkulhan/chrome-devtools-protocol","owner":"jakubkulhan","description":"Chrome Devtools Protocol client for PHP","archived":false,"fork":false,"pushed_at":"2025-05-03T03:02:02.000Z","size":5743,"stargazers_count":178,"open_issues_count":20,"forks_count":51,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-05-03T04:17:53.204Z","etag":null,"topics":["automation","chrome","chrome-devtools","chrome-devtools-protocol","headless","headless-chrome","web"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jakubkulhan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-11-21T16:04:29.000Z","updated_at":"2025-05-03T03:02:05.000Z","dependencies_parsed_at":"2023-02-18T21:31:06.340Z","dependency_job_id":"7196076f-bc07-4d8d-a039-e79c3be53b4b","html_url":"https://github.com/jakubkulhan/chrome-devtools-protocol","commit_stats":{"total_commits":629,"total_committers":8,"mean_commits":78.625,"dds":0.1224165341812401,"last_synced_commit":"5312557074b319a88328f42ebe7ef9b3e093a4d9"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakubkulhan%2Fchrome-devtools-protocol","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakubkulhan%2Fchrome-devtools-protocol/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakubkulhan%2Fchrome-devtools-protocol/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakubkulhan%2Fchrome-devtools-protocol/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jakubkulhan","download_url":"https://codeload.github.com/jakubkulhan/chrome-devtools-protocol/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254270646,"owners_count":22042859,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","chrome","chrome-devtools","chrome-devtools-protocol","headless","headless-chrome","web"],"created_at":"2024-08-04T01:00:53.211Z","updated_at":"2025-05-15T04:06:19.086Z","avatar_url":"https://github.com/jakubkulhan.png","language":"PHP","readme":"# Chrome Devtools Protocol PHP client\n\n[![Build](https://circleci.com/gh/jakubkulhan/chrome-devtools-protocol.svg?style=svg)](https://circleci.com/gh/jakubkulhan/chrome-devtools-protocol)\n[![Latest Stable Version](https://poser.pugx.org/jakubkulhan/chrome-devtools-protocol/v/stable?format=flat)](https://packagist.org/packages/jakubkulhan/chrome-devtools-protocol)\n[![License](https://poser.pugx.org/jakubkulhan/chrome-devtools-protocol/license?format=flat)](https://packagist.org/packages/jakubkulhan/chrome-devtools-protocol)\n\n\u003e PHP client for [Chrome Devtools Protocol](https://chromedevtools.github.io/devtools-protocol/).\n\n## Basic usage\n\n```php\n// context creates deadline for operations\n$ctx = Context::withTimeout(Context::background(), 30 /* seconds */);\n\n// launcher starts chrome process ($instance)\n$launcher = new Launcher();\n$instance = $launcher-\u003elaunch($ctx);\n\ntry {\n\t// work with new tab\n\t$tab = $instance-\u003eopen($ctx);\n\t$tab-\u003eactivate($ctx);\n\n\t$devtools = $tab-\u003edevtools();\n\ttry {\n\t\t$devtools-\u003epage()-\u003eenable($ctx);\n\t\t$devtools-\u003epage()-\u003enavigate($ctx, NavigateRequest::builder()-\u003esetUrl(\"https://www.google.com/\")-\u003ebuild());\n\t\t$devtools-\u003epage()-\u003eawaitLoadEventFired($ctx);\n\n\t\t// ... work with page ...\n\t\t// e.g.\n\t\t// - print to PDF: $devtools-\u003epage()-\u003eprintToPDF($ctx, PrintToPDFRequest::make());\n\t\t// - capture screenshot: $devtools-\u003epage()-\u003ecaptureScreenshot($ctx, CaptureScreenshotRequest::builder()-\u003esetFormat(\"jpg\")-\u003esetQuality(95)-\u003ebuild());\n\n\t} finally {\n\t\t// devtools client needs to be closed\n\t\t$devtools-\u003eclose();\n\t}\n\n} finally {\n\t// process needs to be killed\n\t$instance-\u003eclose();\n}\n```\n\n## Headless Chrome isolated contexts\n\nHeadless 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.\n\nUnlike incognito windows, there can be multiple isolate *browser contexts* at the same time.\n\n```php\n$ctx = Context::withTimeout(Context::background(), 10);\n$launcher = new Launcher();\n$instance = $launcher-\u003elaunch($ctx);\ntry {\n\t$session = $instance-\u003ecreateSession($ctx);\n\ttry {\n\n\t\t// $session implements DevtoolsClientInterface, same as returned from Tab::devtools()\n\n\t} finally {\n\t\t$session-\u003eclose();\n\t}\n} finally {\n\t$instance-\u003eclose();\n}\n```\n\n## Using an already running Chrome browser\n\n```php\nuse ChromeDevtoolsProtocol\\Instance\\Instance;\n\n$instance = new Instance(/* host: */ \"localhost\", /* port: */ 9222);\n\n\n$ctx = Context::withTimeout(Context::background(), 30 /* seconds */);\n\n$tab = $instance-\u003eopen($ctx);\n$tab-\u003eactivate($ctx);\n\n$devtools = $tab-\u003edevtools();\n\n// ...work with devtools\n\n// no need to call -\u003eclose() as no new process is started\n```\n\n## License\n\nLicensed under MIT license. See `LICENSE` file.\n","funding_links":[],"categories":["Chrome DevTools Protocol"],"sub_categories":["Libraries for driving the protocol (or a layer above)"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjakubkulhan%2Fchrome-devtools-protocol","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjakubkulhan%2Fchrome-devtools-protocol","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjakubkulhan%2Fchrome-devtools-protocol/lists"}