Composer Package Executor (CPX) - bring NPX to Composer

Tired of managing different development tools across projects? cpx (Composer Package Executor) is a handy tool developed by Liam Hammett that simplifies your workflow. Similar to npx for npm, cpx allows you to run any command from a Composer package, even if it's not installed in your project.

Say goodbye to version conflicts and installation hassles. cpx takes care of package installations and updates behind the scenes, letting you focus on what matters - coding. This ensures consistency across your projects, whether you're working solo or collaborating in a team.

To install cpx you do so using composer:

composer global require cpx/cpx

Then, you execute any composer package by doing:

cpx vendor/package <command>

For example:

cpx laravel/installer new
 
# Or, for popular packages, you can use the command's alias directly
 
cpx laravel new

If you switch between numerous projects, they may use different tooling and so cpx will help to normalize your workflow by providing commands that actually detect what tools your project is using and uses the correct one for you. Are you working on a project that uses Pests for testing? No problem! cpx automatically detects your project's testing framework (including PHPUnit or Codeception) and runs the appropriate tests with cpx test. Similar logic applies to static analysis with cpx check, which detects PHPStan, Psalm, or Phan, and code formatting with cpx format, which works with PHP-CS-Fixer, Laravel Pint, or PHPCBF.

cpx also integrates nicely with Laravel and so your app will be bootstrapped so you can use any Laravel service.

Learn more about this tool at cpx.dev and view the source code on GitHub.


The post Composer Package Executor (CPX) - bring NPX to Composer appeared first on Laravel News.

Join the Laravel Newsletter to get all the latest Laravel articles like this directly in your inbox.