Package for your app – it allows your App to check himself has consistent vendor dir (direct API, no CLI).
composer.json <== (synchronized) ==> /vendor
For small teams can be difficult to cooperate and keep /vendor directory synchronized with requirements in composer.json. Your colleagues can be a junior or can be not accustomed to right use the Composer.
You can force refresh Composer via git-hooks, or push all /vendor into your repo, but it's very dirty way. Don't do it!
Or… just add this package to you project. It checks if you /vendor is consistent with project and can notify you and your colleagues to forgotten refresh.
Add this package to project as dev-dependency:
composer require --dev jakubboucek/composer-vendor-checkerIn your app just call validateReqs() method:
<?php use JakubBoucek\ComposerVendorChecker\Checker; Checker::validateReqs(__DIR__);When /vendor is not consistent with composer.json, checker throws an Exception.
Because you install Checker as dev-dependency, you should be very careful to hard-linking dependency insinde your App. Is highly recommended to call validation only on development stage, not on production:
if(Debugger::$productionMode === false) { Checker::validateReqs(__DIR__); }Or check if dependency exists:
if(class_exists(Checker::class)) { Checker::validateReqs(__DIR__); }Contructor creates Checker instance.
Only required argument is absolute path to root directory (directory where checker search the composer.lock file).
Optional argument is absolute path do vendor directory. Default is {$rootDir}/vendor.
Check if /vendor is consitent with app requirements and throw an Exception if is not.
Check if /vendor is consitent with app requirements and return boolean of consistency status.
Shortcut to call validate() without creating Checker instance before.
