Class "App" not found

Hi there,

I’m starting to create my first custom panel menu. I just copied-pasted the sample code from the reference to my config and I’ve got an error : Class "App" not found.

I’m using version 4.0.3, installed through composer.

Here is my full config.php :


return [
  'debug' => true,
  'panel' => [
    'menu' => [
      'site' => [
        'label' => 'Overview'
      'notes' => [
        'icon'  => 'pen',
        'label' => 'Notes',
        'link'  => 'pages/notes',
        'current' => function ($current) {
          $path = App::instance()->request()->path()->toString();
          return Str::contains($path, 'pages/notes');

If you want to use the App class directly you have to include the namespace in your file.

use Kirby\Cms\App;


// Or use the alias

// Or use the helper function

You need to import the class or use the Fully Qualified name::


Thank you !

Why it isn’t necessary for the Kirby class to be imported ?
Why the sample from the reference is using the App class instead of the Kirby one ?

Kirby is not a class name but a class alias that is made available globally.

1 Like

The Kirby alias is registered without a namespace. So the fully qualified name is simply Kirby.

1 Like

Sorry, missed that you beat me to it, @lukaskleinschmidt

No worries :slight_smile:

Regarding the usage in the example. It would probably make sense to either include the use statement or use one of the other two ways to get the kirby instane. The v4 docs are still pretty new and especially the menu option was not available in v3. So not many people came across this issue yet I guess.

I already fixed the page in the docs. Need to check if we are using it in other places as well.

1 Like

On a side note: An IDE should usually warn you and offer to import undefined classes (and other issues). In PHPStorm, for example, I get this warning:

I understand. Thank you both.