You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Checking composer.json: WARNING
License "GPL-2.0+" is a deprecated SPDX license identifier, use "GPL-2.0-or-later" instead
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com oauth access: OK
Checking disk free space: OK
Checking pubkeys:
Tags Public Key Fingerprint: 57815BA2 7E54DC31 7ECC7CC5 573090D0 87719BA6 8F3BB723 4E5D42D0 84A14642
Dev Public Key Fingerprint: 4AC45767 E5EC2265 2F0C1167 CBBB8A2B 0C708369 153E328C AD90147D AFE50952
OK
Checking composer version: OK
Composer version: 1.7.2
PHP version: 7.1.16
PHP binary path: /usr/bin/php
When I run this command inside my script fired as post-install-cmd:
use Symfony\Component\Filesystem\Filesystem;
$fs = new Filesystem();
$a = new \ReflectionClass($fs);
echo $a->getFileName();
$ composer create-project leymannx/wordpress-project some-dir --stability dev --no-interaction (I echo the output with the outdated/wrongly(?) loaded file path)
The text was updated successfully, but these errors were encountered:
Well, during the run of composer itself, the code coming from the phar is being used. that's totally expected, as PHP does not allow redefining classes, and the code from composer is loaded first in the process (to run composer itself).
If your script requires using your own deps and not the version shipped in a composer, a solution is to a use a CLI script rather than a PHP callable as the script (as it means the code will run in a separate PHP process with its own loading of classes)
My question on Stack Overflow got answered and finally pointed me in the right direction. All I needed to do was to require_once __DIR__.'/../vendor/autoload.php'; at the top of my script.
If you install this component outside of a Symfony application, you must require the vendor/autoload.php file in your code to enable the class autoloading mechanism provided by Composer.
leymannx
changed the title
How to force Composer to load local symfony/filesystem instead of global Composer's symfony/filesystem
How to force Composer to load local symfony/filesystem instead of global Composer's symfony/filesystem in post-install-cmd script
Oct 12, 2018
My
composer.json
:Output of
composer diagnose
:When I run this command inside my script fired as
post-install-cmd
:I get the following output:
And I expected this to happen:
What else?
Steps to reproduce
$ composer create-project leymannx/wordpress-project some-dir --stability dev --no-interaction
(I echo the output with the outdated/wrongly(?) loaded file path)The text was updated successfully, but these errors were encountered: