Composer Scripts and Autoloading
Define scripts in composer.json and enable class autoloading.
Scripts in composer.json
The scripts key defines named shell commands that run via composer run-script NAME or just composer NAME.
Defining a Script
Scripts are arrays of shell commands or PHP static-method callbacks.
// composer.json
{
"scripts": {
"test": "vendor/bin/phpunit",
"lint": "vendor/bin/phpcs src/",
"cs-fix": "vendor/bin/phpcbf src/"
}
}All lessons in this course
- Installing and Initializing Composer
- Requiring and Updating Packages
- Understanding composer.lock
- Composer Scripts and Autoloading