Composer供应商在另一个供应商文件夹中安装

Let's say I have two packages package and package-extensions. So let's say package upon install, goes to /vendor/package/src. This package will have something like /vendor/package/src/replace.php.

Next, I want to install package-extensions such that it replaces /vendor/package/src/replace.php file.

Is that possible?

AFAIK you can't, but you can add to the composer.json a post-install event script to do it.

https://getcomposer.org/doc/articles/scripts.md#installer-events

Unfortunately, you'll have to add the post-install script in the compsoser.json of the project using package and package-extension. It won't work if you add the script in the composer.json of package-extension because composer doesn't run the event scripts of the dependencies.