2 Methods to Run Vendored Script Installed with Composer

2 Methods to Run Vendored Script Installed with Composer

Managing scripts from Composer-installed packages is a routine part of maintaining PHP projects. Many packages include executable scripts, such as testing frameworks, code analyzers, or build utilities, which are placed in the vendor/bin directory. This tutorial provides 2 methods how to run vendored script installed with Composer.

Method 1 - direct execution

Many Composer packages place executable scripts in the vendor/bin directory. To run a script directly, navigate to the project root and execute it using the relative path. For example, to run PHPUnit:

vendor\bin\phpunit
vendor/bin/phpunit

Method 2 - using Composer

Composer also provides the exec command to run any installed package script without specifying the full path. The command automatically resolves the script location:

composer exec phpunit

Leave a Comment

Cancel reply

Your email address will not be published.