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.

View on GitHub
Deep Wiki
Context7

Instrument headless chrome/chromium instances from PHP

Frequently asked questions about Chrome
What Laravel versions does chrome-php/chrome support?
The package works with Laravel 10/11, but **PHP 8.6+ is now required**. Laravel 11 on PHP 8.6+ is fully supported, while older Laravel versions (PHP 8.2–8.5) may need to use v1.16.0 or pin PHP 8.6. Verify your deployment’s PHP version first.
How do I install chrome-php/chrome in Laravel?
Run `composer require chrome-php/chrome` in your project. Ensure PHP 8.6+ is installed, as older versions will break due to `trim()` changes. For Docker, include Chromium in your image (e.g., `chromium:latest`).
Can I use this package for server-side scraping in Laravel?
Yes, it’s ideal for scraping. Launch Chromium via `BrowserFactory`, navigate pages with `createPage()`, and extract data using `evaluate()`. For async scraping, pair it with ReactPHP or Swoole. Cache Chrome instances to improve performance.
Will this work in production? What about memory leaks?
It works in production, but monitor memory usage. Set `maxMemory` in the browser config to limit resource usage, and kill stale processes if needed. Docker containers help isolate Chromium’s resource demands.
How do I take screenshots or generate PDFs with this package?
Use `$page->screenshot()->saveToFile('path.png')` for screenshots and `$page->pdf(['options'])->saveToFile('path.pdf')` for PDFs. Both methods return promises; chain `.then()` for async workflows or use `getReturnValue()` for sync.
What if my Laravel app uses PHP 8.2 or lower? Can I downgrade?
Downgrade to **v1.16.0** of the package to support PHP 8.2–8.5, but note this may lack PHP 8.6+ optimizations. Alternatively, update your Laravel app to PHP 8.6+ or consider alternatives like `playwright-php` (PHP 8.1+).
How do I debug Chrome instances launched by this package?
Disable headless mode by passing `['headless' => false]` to `createBrowser()`. This opens a visible Chrome window for debugging. Use `CHROME_PATH` to specify a custom executable if needed.
Is there a way to intercept network requests like Puppeteer?
Yes, use `$browser->on('request', function($request) { ... })` to intercept network events. This lets you modify requests, block resources, or log traffic—similar to Puppeteer’s request handling.
What are the alternatives if chrome-php/chrome doesn’t fit my stack?
Consider `playwright-php` (PHP 8.1+, multi-browser), `symfony/dom-crawler` (lightweight HTML parsing), or Node.js `puppeteer` (if PHP isn’t a constraint). For Laravel-specific needs, check `spatie/laravel-browser-kit` for simpler SSR.
How do I integrate this with Laravel’s service container?
Bind the `BrowserFactory` in `AppServiceProvider`’s `register()` method, then inject it into controllers or commands. Example: `app()->bind(BrowserFactory::class, fn() => new BrowserFactory());`. Use facades or dependency injection for cleaner code.
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.
calmfox/watch-sylius
damienfern/grpc-symfony-bundle
atoolo/index-bundle
atoolo/genai-bundle
coprotoai/laravel-ticket
davidjln/llm-carbon-bundle
cryonighter/valid-request-bundle
coolms/taxonomy-bundle
coolms/field-bundle
articulate-orm/symfony
aaix/laravel-tall-architect
ephoto/akeneo-connector
emmanuelballery/eb-plantumlbundle
emielburgman/symfony-visitor-beacon
emielburgman/symfony-visit-storage
emielburgman/symfony-security-headers
emielburgman/symfony-log-viewer
emarref/xdebug-bundle
emarref/pubnub-bundle
elriseio/finance-money-bundle