Plugin Namespacing Convention

I’m wondering what would be the best way to namespace classes in a plugin. Here are a few suggestions:

  1. Author\Kirby\Plugin
  2. Author\Plugin
  3. Kirby\Plugin\Author\Plugin (verbose, but accurate)
  4. Kirby\Plugin\Plugin (OK, potential for collisions with plugins by different authors)
  5. Kirby\Plugin (bad idea)

Bold parts are variable. I sorted them for most favorite to least favorite. The highest ranked was the last to come to mind, but I think it makes most sense. Using Kirby as the starting prefix is probably pretty bad in all 3 cases because it’s not actual source code from Kirby…

If you have a plugin called “foo” it would be best, in my opinion, to use:

  • Namespace: You\Kirby\Foo
  • GitHub repo: you/kirby-foo
  • Composer package: you/kirby-foo
  • Registered name in plugin index.php: you/foo


1 Like