Get Path of current page

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.

Use $this->grav['page'] to have access to the current Page object

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.