Free tools Windows power users keep installed
One-click scans. No signup required.
PHP cannot run Puppeteer directly because Puppeteer is a Node.js library. The reliable pattern is to keep browser automation in a JavaScript file, invoke that file from PHP with a fixed, escaped command, and return one machine-readable result (usually JSON) on standard output. Send diagnostics to standard error, and use exec() or proc_open() when you need an exit code or separate output streams; shell_exec() captures output but does not report whether the command succeeded.
The architecture: PHP starts Node, Node runs Puppeteer
A request flows through two processes:
- PHP validates the job and launches a known Node.js executable plus a known script path.
- Node.js imports Puppeteer, starts a browser, performs navigation or interaction, writes a compact JSON result, and closes the browser.
- PHP parses the JSON and decides whether the job succeeded.
Keep the browser code in JavaScript rather than embedding a large script in a shell command. This makes deployment, testing and escaping manageable.
Install Node.js and Puppeteer
Create an isolated Node project
From the application directory:
mkdir browser-worker
cd browser-worker
npm init -y
npm install puppeteer
The standard puppeteer package downloads a compatible Chrome during installation. If your package manager blocks install scripts, that browser download may not happen. Install it explicitly with:
npx puppeteer browsers install
Use puppeteer-core instead when your deployment already supplies and manages a browser executable; with that package, browser management is your responsibility.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
Verify the runtime as the web worker
An interactive shell can have a different PATH, home directory and permissions than PHP-FPM, Apache or another service account. Find the absolute Node path (for example, /usr/bin/node) and ensure that account can read the project, start the browser, create temporary files and write the intended output directory. Do not assume that a browser installed for your login is visible to the PHP worker.
Build a Node.js worker that returns JSON
Create automation.js in the Node project. This example opens a URL supplied as a command-line argument, waits for the page to load, captures a screenshot, and emits exactly one JSON object on standard output. Errors go to standard error.
const puppeteer = require('puppeteer');
async function main() {
const target = process.argv[2];
if (!target || !/^https?:\/\//i.test(target)) {
throw new Error('A valid http(s) URL is required');
}
const browser = await puppeteer.launch({
headless: true
});
try {
const page = await browser.newPage();
await page.goto(target, {
waitUntil: 'networkidle2',
timeout: 60_000
});
const title = await page.title();
const outputFile = '/tmp/puppeteer-shot.png';
await page.screenshot({ path: outputFile, fullPage: true });
process.stdout.write(JSON.stringify({
ok: true,
url: page.url(),
title,
screenshot: outputFile
}) + '\n');
} finally {
await browser.close();
}
}
main().catch((error) => {
process.stderr.write((error.stack || String(error)) + '\n');
process.stdout.write(JSON.stringify({ ok: false }) + '\n');
process.exitCode = 1;
});
In production, choose an output path owned by the worker and generate a per-job filename rather than sharing /tmp/puppeteer-shot.png. The example deliberately validates the URL before it reaches the browser; apply your own allow-list if users can choose destinations.
Pass data without making shell syntax
A command-line argument is convenient for a demonstration, but never concatenate an untrusted URL, filename or option into a command string. Either escape each value with escapeshellarg() or pass structured input through standard input with proc_open(). The Node process should also validate the value it receives.
Call the worker from PHP with shell_exec()
Use an absolute executable and an absolute script path. Escape each argument as one shell argument:
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
<?php
$node = '/usr/bin/node';
$script = __DIR__ . '/browser-worker/automation.js';
$target = 'https://example.com';
$command = escapeshellarg($node) . ' '
. escapeshellarg($script) . ' '
. escapeshellarg($target);
$output = shell_exec($command);
if ($output === false || $output === null || trim($output) === '') {
throw new RuntimeException('The worker produced no usable output');
}
$result = json_decode($output, true, 512, JSON_THROW_ON_ERROR);
if (($result['ok'] ?? false) !== true) {
throw new RuntimeException('Browser automation failed');
}
echo htmlspecialchars($result['title'] ?? '', ENT_QUOTES, 'UTF-8');
shell_exec() returns captured output as a string, false if the pipe cannot be established, or null when an error occurs or no output is produced. That null value is ambiguous: no output can look like an execution problem. Also, shell_exec() does not expose the command’s exit status, so output text alone is not a reliable success test.
In the worker above, a failed job writes a JSON object and exits non-zero. With shell_exec(), PHP still cannot read that exit code. If status matters, use exec():
<?php
$lines = [];
$status = 0;
exec($command, $lines, $status);
$output = implode("n", $lines);
if ($status !== 0) {
throw new RuntimeException('Node exited with status ' . $status);
}
$result = json_decode($output, true, 512, JSON_THROW_ON_ERROR);
For separate standard output and standard error, input streaming, timeouts, termination and more explicit process control, use proc_open(). Keep any redirection such as 2>&1 fixed in your program, never derived from request data.
Capture errors without corrupting the JSON protocol
Reserve standard output for the response PHP must parse. Browser console messages, progress logs and stack traces belong on standard error. If you merge streams, diagnostics can make JSON invalid. Log the command, elapsed time, exit status and a sanitized error message, but do not log secrets such as cookies, authorization headers or private URLs.
Timeouts and cleanup
Set a navigation timeout in Puppeteer and enforce an outer process timeout in PHP or your job runner. Always close the browser in a finally block. Without cleanup, failed requests can leave Chromium processes consuming memory and file descriptors. For repeated jobs, a queue or long-lived worker can avoid launching a browser for every HTTP request, but it requires explicit concurrency, recycling and crash recovery policies.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Security boundaries you must enforce
- Control the executable and script. Use configured absolute paths; never let a request select a binary or JavaScript file.
- Escape arguments. Use
escapeshellarg()for each single argument, not string concatenation around raw input.escapeshellcmd()is not a substitute for per-argument handling. - Restrict destinations. A browser that can visit arbitrary URLs can become an SSRF path into internal services. Permit only required schemes, hosts or networks, and decide how redirects are handled.
- Limit privileges. Run the PHP worker and browser with the smallest filesystem and network permissions practical.
- Protect returned content. A page title, text or HTML is untrusted data. Escape it before inserting it into an HTML response, and do not execute page-provided JavaScript in your application.
- Protect secrets. Pass credentials through a controlled mechanism, avoid command-line arguments for secrets where process listings expose them, and redact logs.
Puppeteer’s security policy places responsibility for safe browser installation, automation and inspection on the calling code. Treat the Node process as a separate security boundary, not as trusted application code.
Platform and deployment differences
Linux and macOS
Confirm the PHP service account can execute Node, read the project and browser cache, and access required shared libraries. A minimal server image may need additional Chromium dependencies. Check the service account’s environment rather than your terminal’s environment.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Windows
PHP execution functions normally invoke commands through cmd.exe. The caller needs appropriate privileges, and quoting rules differ from POSIX shells. PHP documents proc_open() with bypass_shell as the exception when you need to avoid that shell path. Test with the same account used by IIS, Apache or the PHP worker.
Troubleshooting common failures
“shell_exec() is disabled” or no process starts
Check PHP configuration for disabled execution functions and verify that the web-server account can execute the absolute Node path. If policy forbids shell execution, move the browser worker behind a local service or queue instead of bypassing the restriction.
Node works in SSH but not from PHP
Use the absolute executable path, inspect the worker’s PATH and home directory, and test permissions as the service account. Environment managers that modify interactive shells often are not loaded by PHP.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
“Cannot find module puppeteer”
Run the script from the project whose node_modules contains Puppeteer, or set the correct working directory in a process API. Confirm that installation completed successfully.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minuteChrome or browser executable missing
The package install script may have been blocked. Run npx puppeteer browsers install, or use puppeteer-core only when you intentionally provide an executable and configure it.
PHP receives null or an empty string
The worker may have produced no standard output, crashed before writing its result, or lacked permission to start. Ensure every success and failure path writes a JSON line, and send diagnostics to standard error for inspection.
JSON parsing fails
Remove debug prints from standard output. Keep logs on standard error and ensure the PHP side reads only the worker’s protocol output.
Navigation times out or hangs
Set explicit Puppeteer timeouts, choose an appropriate waitUntil condition, and account for pages that keep long-lived connections open. Capture a useful error and always close the browser.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteBest Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Works locally, fails in production
Compare Node and browser versions, filesystem permissions, temporary-directory policy, available shared libraries, outbound network rules and service-account limits. Reproduce with the same account and environment rather than an administrator shell.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.When shell_exec() is the wrong process API
| Need | Better choice | Reason |
|---|---|---|
| Only simple captured text | shell_exec() |
Smallest interface, but no exit status and ambiguous null. |
| Exit code plus output lines | exec() |
Returns an exit-status value separately. |
| Separate stdout/stderr, stdin, timeouts or lifecycle control | proc_open() |
Provides explicit pipes and process management. |
| Avoiding an intermediate shell on Windows | proc_open() with bypass_shell |
PHP documents this as the Windows exception to the normal cmd.exe path. |
Choose the simplest API that still gives you the failure information and control your application requires. For a synchronous web request, impose a server-side request timeout shorter than the browser’s maximum; for longer work, enqueue the job and return a status identifier.
Performance, reliability and cost considerations
- Browser startup: launching Chromium is expensive compared with a normal HTTP request. Reuse a controlled browser only when you can isolate pages, cap concurrency and recycle unhealthy processes.
- Memory: full-page screenshots, multiple tabs and heavy client-side applications increase memory use. Limit concurrent jobs and monitor the PHP and Node workers separately.
- Network variability: third-party scripts and pages that never become idle can extend runs. Use targeted selectors or a bounded delay when “network idle” is not appropriate.
- Failure accounting: record duration, exit code, navigation error and browser cleanup outcome. A successful process with an invalid business result is not a successful job.
- Deployment cost: Puppeteer itself has no PHP runtime integration; you operate Node, Chromium, temporary storage and the process supervisor. A queue or dedicated browser service may be cheaper operationally than spawning browsers inside every PHP request.
Or skip the browser setup
If your goal is a dependable website screenshot rather than custom browser automation, ScreenshotNeo provides a single API request and an MCP server for AI clients. It removes cookie/consent banners, newsletter popups and chat widgets before capture; bot checks, blank pages, timeouts, failed loads and cache hits are not billed, and response headers identify the page verdict and billing result. Its MCP tools—take_screenshot, get_page_info and capture_pdf—work with Claude, Cursor and other MCP clients.
One cURL request:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo documentation for all options, including full-page and element captures, device presets, dark mode, custom CSS and JavaScript, waits, request blocking, cookies and headers, geolocation, PDF output, caching, signed links, asynchronous jobs and bulk capture.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Equivalent Python:
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
Equivalent Node.js:
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
The Free plan includes 1,000 screenshots per month with no card. Paid plans start at $5 for 3,000 shots; every feature is available on every plan. Create a free ScreenshotNeo account.
Frequently Asked Questions
Can PHP include Puppeteer directly?
No. Puppeteer is a Node.js library, so PHP must communicate with a Node process or a separate browser service.
How do I know whether a shell_exec() call really failed?
You cannot determine that from shell_exec() alone. Use exec() for an exit code or proc_open() for explicit process status and streams.
Should I use puppeteer or puppeteer-core?
Use puppeteer when you want its installation process to download a compatible Chrome. Use puppeteer-core when your application deliberately manages the browser executable.
Why does the same command behave differently in production?
The PHP worker may have a different account, PATH, home directory, permissions, browser cache or system libraries than your interactive shell.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

