Class "MarkdownPlus" not found (in panel)

Hi

I’m trying to understand the example /site/plugins/markdown-parser/index.php:

Kirby::plugin('my/markdown', [
	'components' => [
		'markdown' => function (Kirby $kirby, string $text = null, array $options = [], bool $inline = false) {
			return YourMarkdownParser::parse($text);
		}
	]
]);

I assume that I have to place the implementation of YourMarkdownParser inside the plugin folder. Right?

Could I instead do

'markdown' => function (Kirby $kirby, string $text = null, array $options = [], bool $inline = false) {
	require_once __DIR__ . 'YourMarkdownParser.php';
	$my = new YourMarkdownParser();
	return $my->parse($text);
}

Actually, I tried that and it seems to work. Except that I get an error message in the page panel: Class “YourMarkdownParser” not found

So, what did I get wrong here?

I guess I’d have to somehow make Kirby be aware of my new Class, right?
If so, how do I do that?

Thanks,
Dieter

You should load your class in your plugin’s index.php

Yep, that worked! Thanks.

Would it be possible to make Kirby’s autoloader find my new class automatcally?

Well, you have to tell Kirby what files to load when the classes are requested see docs: