vendredi 6 septembre 2019

How to get relative vendor path of a class file by name using composer?

I have a class name Illuminate\Support\ServiceProvider

I want to get the relative path of that class file, should be like

vendor/laravel/framework/src/Illuminate/Support/ServiceProvider.php

Using ReflectionClass

$reflector = new \ReflectionClass('Illuminate\Support\ServiceProvider');
echo $reflector->getFileName();

I get

/home/user/project/vendor/laravel/framework/src/Illuminate/Support/ServiceProvider.php

is there a way to get the relative file path using Composer since I have an instance of Composer\Script\Event passed to my function by dependency injection





Aucun commentaire:

Enregistrer un commentaire