Run Composer packages,
effortlessly.

The entire ecosystem, always at your fingertips.

Get cpx now Check out the features
see how easy it is to use!
|

Thousands of tools in the palm of your hand

Run any Composer package's commands on-the-fly

cpx lets you invoke a command from any Composer package with ease.

Just run it.
Just run cpx vendor/package to invoke the command from a package. If a package has more than one command, pass through the command name like cpx vendor/package <command>
If you need to pass further arguments or options to the command, append them on the end. It's just intuitive.
No installation.
No need to install the dependency into your package or into your global Composer install. cpx handles package installations and updates behind-the-scenes so you don't have to worry about it.
No dependency conflicts.
cpx ships as a self-contained PHAR with its own dependencies bundled and isolated inside it, and it keeps any packages you run separate from the rest of your code, so there's no chance for conflicts when running different commands.
Always up-to-date.
cpx periodically checks if there's an update to packages you run, so you always get the latest and greatest without needing to worry about updating it manually.
|

Made to fit the project you're in

Your tools, your shortcuts

When you switch between lots of projects, they don't all pin the same versions of the same tools — and nobody wants to type friendsofphp/php-cs-fixer more than once.

cpx uses what your project already has, and lets you name the rest.

Local binaries first.
Just like npx, cpx pint runs your project's own vendor/bin/pint when it's installed, so you get the version your project pins. Otherwise cpx installs and runs an isolated copy. Pass --skip-local to always use the isolated one.
cpx alias
Name any package whatever you like — cpx alias friendsofphp/php-cs-fixer gets you cpx php-cs-fixer from then on. Review yours with cpx aliases , drop one with cpx unalias .
cpx installed
See every package you've run through cpx and when you last used it. cpx update brings them up to date, and cpx clean clears out the ones you've stopped reaching for.
Scriptable output.
Outside an interactive terminal — piped, --no-interaction , or driven by an AI agent — cpx's own commands answer with a single line of JSON, and package runs stream nothing but the tool's own output. Pass --json to get it any time.
|

Helping you write code fast

Superpowers for running PHP

cpx gives you multiple ways to run PHP code quickly, perfect for running scratch files or quickly running code in your project.

  • cpx exec <file.php> will run a plain PHP file.
  • cpx exec -r <raw php code> will execute the given PHP code.
  • cpx exec <gist url> will download a GitHub gist and run it.
  • cpx tinker will open an interactive REPL in the terminal for your project.

But what is it you get from this over just using php or php -r or psysh directly?

You get all this:
Automatic project autoloaders
Any Composer autoloaders in the directory are included automatically, so you can access and use your project code effortlessly.
Dynamic packages
Use cpx_require('vendor/package') in your scratch file to dynamically include packages for testing purposes.
Class aliasing
If you use a class without referencing its full namespace, cpx will figure it out for you, no need for "use" statements.
Framework bootstrapping
In a Laravel project the whole app is booted, so config, facades and $app just work. In a Symfony project you get the booted kernel and container. Pass --no-boot to skip it.
Already using cpx 1.x? The 1.x series is frozen — read the upgrade guide to move to 2.x, then run composer global require cpx/cpx:^2.0

Made with for the PHP community by the Laravel team