I am currently writing my first plugin for Grav and was wondering, how to get the path to the .md file which is currently opened using php.
Got get to the actual file, you can use:
$page->filePath()
How you get page depends on which event you are in. You can look in other plugins for examples.