Get loaded path for a class in PHP

If you have a class MyClass loaded via Composer, use this snippet to find the path to the class definition:

$reflection = new ReflectionClass( 'MyClass' );
echo $reflection->getFileName();

🔥 HOT: Interested in boosting your WordPress SEO? My Slim SEO plugin is a super lighweight and automated plugin that handles most the hard work for you: meta tags, sitemap, redirection, schema & link building.

👉 Have a look and you will love it: wpslimseo.com

Copyright © 2024 Deluxe Blog Tips. All rights reserved.

My products: Meta Box | Slim SEO