phpx logo

Run PHP scripts with inline dependencies

Execute Composer tools without global installation.
Like npx and uvx for PHP.

$ brew install eddmann/tap/phpx

Inline Dependencies

Declare packages in a // phpx comment block at the top of your script. They're installed automatically.

Ephemeral Tools

Run PHPStan, Psalm, PHP-CS-Fixer, and more without polluting your global environment. Tools are cached for fast re-runs.

Automatic PHP Management

Downloads pre-built static PHP binaries matching your version constraints. No system PHP required.

Smart Caching

PHP binaries, dependencies, and tools are intelligently cached at ~/.phpx/ for instant subsequent runs.

Secure by Design

Run untrusted scripts safely with built-in sandboxing. Control filesystem access, network, and resource limits.

Filesystem Isolation

Restrict access to only what scripts need

Network Control

Block network or allow specific hosts

Resource Limits

Control memory, CPU, and execution time

$ phpx script.php --sandbox --allow-read /data --allow-write /tmp

Uses sandbox-exec on macOS, bubblewrap on Linux

Quick Start

Add a comment block to declare dependencies, then run your script.

script.php
<?php
// phpx
// packages = ["nesbot/carbon:^3.0"]
echo \Carbon\Carbon::parse('next friday')->diffForHumans();
terminal
$ phpx script.php
6 days from now
terminal
# Run PHPStan without installing it globally
$ phpx tool phpstan -- analyze src/