DokuWiki

It's better when it's simple

User Tools

Site Tools


devel:autoloader

Autoloader

DokuWiki registers its own autoloader early on in inc/load.php. When developing plugins you nearly never need to require any other files yourself.

Plugin components are automatically recognized by their naming scheme and file_structure. However those should always be loaded via plugin_load() or loadHelper().

If you need additional classes, simply use the appropriate namespace as outlined below.

Vendor Autoload

When plugins have a vendor/autoload.php file it is automatically required by DokuWiki's autoloader. No need do that yourself anymore.

Namespaces

Because of DokuWiki's long history, most core files are not namespaced. Newer components however are.

DokuWiki registers the following namespaces for autoloading:

  • \dokuwiki\ - classes and subnamespaces are loaded from inc/*
  • \dokuwiki\test - used with unittesting, classes and subnamespaces are loaded from _test/tests/*
  • \dokuwiki\test\mock - used with unittesting, classes and subnamespaces are loaded from _test/mock/*
  • \dokuwiki\plugin\ - classes are loaded from lib/plugins/*
  • \dokuwiki\plugin\*\test\ - classes are loaded from lib/plugins/*/_test/*
  • \dokuwiki\template\ - classes are loaded from lib/tpl/*
  • \dokuwiki\template\*\test\ - classes are loaded from lib/tpl/*/_test/*
devel/autoloader.txt · Last modified: 2024-02-06 14:09 by andi

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki