According to docs, composer install
(composer update
too, since it includes install
script), among other things, downloads the requirements
and puts these packages inside the vendor
directory: https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies :
It then implicitly runs the install command. This will download the dependencies' files into the vendor directory in your project.
What the docs don't say is: we often write the following in composer.JSON
...
"require": {
"php": "^8.0",
... so if we try to apply what the docs say, it means that Composer would download the PHP interpretor (a package available in Packagist for example) and put it inside the vendor
directory, when we run either composer install
or composer update
. What is the interest of putting a PHP interpretor inside a site's folder (here, vendor
)?
But we know it doesn't do that. It won't download any PHP interpretor. It won't obviously put it inside the vendor
directory. Instead, it will just check the server's PHP interpretor's version and returns a fatal error or something else if this version doesn't match the requirement
's version.
So does it mean that in the Composer's install
and update
scripts, there is an exception made for PHP when treating the require
's lines in the composer.JSON
file?