I would like to copy some file located inside a package after I installed this package from Composer.
Actually, I would like that, after I install or update a package from Composer, copy some file which might be inside the downloaded package to another directory. I use scripts, with the post-package-install and post-package-update command, but I do not find how to get the install path.
This is my current script :
use Composer\Script\PackageEvent;
class MyScript {
public static function copyFiles(PackageEvent $event)
{
$package = $event->getOperation()->getPackage();
$originDir = $package->someFunctionToFind(); #Here, I should retrieve the install dir
if (file_exists($originDir) && is_dir($originDir)) {
//copy files from $originDir to a new location
}
}
}
Does anybody knows how to get the install dir of the installed/updated package from the PackageEvent class (which is provided in parameter) ?
NOTE :
I tryed $event->getOperation()->getPackage->targetDir() but this does not provide the install path, but the targetDir of the package, defined in composer.json