Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Chrome Laravel Package

chrome-php/chrome

Control headless Chrome from PHP. chrome-php/chrome launches Chromium/Chrome, lets you navigate pages, evaluate JavaScript, take screenshots/PDFs, intercept network events, and automate workflows via the DevTools protocol—ideal for scraping, testing, and rendering.

Deep Wiki
Context7

chrome-php/chrome is a PHP library for driving headless Chrome/Chromium via the Chrome DevTools Protocol (CDP). It lets you launch and control a real browser from PHP to automate navigation, capture pages, and generate artifacts—useful for scraping, testing, and server-side rendering.

Designed to be lightweight and framework-agnostic, it offers a programmatic API to manage tabs, run scripts, and wait for page events with fine-grained control.

  • Launch and manage Chrome processes (headless or visible)
  • Create pages, navigate, and wait for DOM/network conditions
  • Execute JavaScript and interact with the page context
  • Capture screenshots and export PDFs
  • Configure timeouts, viewport, user agent, and more
Frequently asked questions about Chrome
How do I install chrome-php/chrome in a Laravel project?
Run `composer require chrome-php/chrome` in your project directory. Ensure PHP 8.1+ is installed, as this package requires it. Chromium or Chrome must also be available in your environment—either system-installed or via Docker.
Can I use this package for server-side rendering (SSR) in Laravel?
Yes, chrome-php/chrome is ideal for SSR. Launch Chrome headlessly, navigate to your routes, and capture the fully rendered HTML. Combine it with Laravel’s caching or queue workers to avoid blocking requests during generation.
What Laravel versions does chrome-php/chrome support?
This package works with Laravel 10 and 11, which require PHP 8.1+. If you’re using an older Laravel version with PHP 8.0 or below, you’ll need to upgrade or check for alternative solutions.
How do I handle memory leaks when running Chrome processes?
Set `maxMemory` in Chrome options to limit resource usage. For long-running tasks, kill stale processes using `pkill -f chrome` or implement a process cleanup mechanism in your Laravel service layer.
Is chrome-php/chrome suitable for scraping dynamic JavaScript-heavy websites?
Absolutely. Unlike static scrapers, this package fully supports JavaScript execution via Chrome’s DevTools Protocol. Use methods like `waitForSelector()` or `waitForNetworkIdle()` to ensure dynamic content loads before scraping.
Can I generate PDFs or screenshots from Laravel API endpoints?
Yes, but offload the task to a queue job to avoid timeouts. For example, create a `GeneratePdfJob` that uses `Chrome::navigate($url)->pdf()` and store the result in Laravel’s filesystem or database.
How do I integrate this with Laravel’s service container?
Bind the `Chrome` class in a service provider using `app()->singleton(Chrome::class, fn() => new Chrome())`. Then inject it into controllers or services via constructor injection for dependency management.
What are the alternatives to chrome-php/chrome for browser automation in PHP?
For simpler static scraping, `symfony/dom-crawler` or `guzzlehttp/guzzle` may suffice. For async workflows, consider `puppeteer` (Node.js) or `playwright-php`. However, chrome-php/chrome is the most direct PHP-native solution for Chrome/Chromium control.
How do I debug issues with Chrome DevTools Protocol commands failing?
Enable Chrome’s debug logging by setting `logLevel` to `debug` in the options. Check the output for CDP errors. For deeper inspection, use `chrome->executeCdpCommand('Network.enable')` to enable network monitoring and log responses.
Can I run chrome-php/chrome in a Dockerized Laravel environment?
Yes, Docker is highly recommended. Use an official Chromium image (e.g., `chromium:latest`) or Alpine-based variants. Ensure your Docker container has enough memory and expose the necessary ports for headless operation.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
comsave/common
alecsammon/php-raml-parser
chrome-php/wrench
lendable/composer-license-checker
typhoon/reflection
mesilov/moneyphp-percentage
mike42/gfx-php
bookdown/themes
aura/view
aura/html
aura/cli
povils/phpmnd
nayjest/manipulator
omnipay/tests
psr-mock/http-message-implementation
psr-mock/http-factory-implementation
psr-mock/http-client-implementation
voku/email-check
voku/urlify
rtheunissen/guzzle-log-middleware