AssetPathResolver may improve with this method.
use Composer\Autoload\ClassLoader;
use ReflectionClass;
/**
* @throws \RuntimeException
*/
public static function getVendorPath(): string
{
$reflector = new ReflectionClass(ClassLoader::class);
$classLoaderPath = $reflector->getFileName();
if ($classLoaderPath === false) {
throw new \RuntimeException('Unable to find Composer ClassLoader file.');
}
$vendorPath = dirname($classLoaderPath, 2);
if (!is_dir($vendorPath)) {
throw new \RuntimeException('Unable to detect vendor path.');
}
return $vendorPath;
}
Use the above method.
Is your feature request related to a problem?
AssetPathResolver may improve with this method.
Describe the desired solution
Use the above method.
Describe the alternatives that you have considered
https://github.com/szepeviktor/package-path/blob/master/src/PackagePath.php#L38
Additional context
No response
Code of Conduct