$browserFactory = new BrowserFactory();
$browser = $browserFactory->createBrowser(array(
'headless' => true,
'ignoreCertificateErrors' => true,
'disableNotifications' => true,
'windowSize' => [
1000,
1000
],
'customFlags' => [
'--remote-allow-origins=http://127.0.0.1'
],
'args' => [
'--no-crashpad',
'--disable-dev-shm-usage',
'--disable-gpu',
'--headless',
'--disable-software-rasterizer',
'--no-sandbox',
'--crashpad-database=/var/www/.local/crashpad'
],
));
$page = $browser->createPage();
$page->setViewport($windowWidth, $windowHeight);
$page->addPreScript('window.confirm = window.alert = function() {};');
$page->navigate($url)
->waitForNavigation(Page::LOAD, 25000);
usleep(100000); // wait 100ms for proper screenshot
$screenshot = $page->screenshot();
When using
chrome-phpto launch a headless Chrome instance on macOS, the Chrome app briefly shows in the Dock during startup. This is unexpected for headless operation and can be disruptive in environments where the Dock visibility should not change (e.g., during screen recordings, kiosk apps, or automated test runners on a developer workstation).OSX 15.7.1
Chrome 140