Load your plugin last

In some cases a plugin needs to run last.

Rename it? Naa

The most simple way to do that is to rename it to the last character in the alphabet.


Awesome? Naa, it does not look that good.

Load all the other plugins first

Instead of renaming it, use this in your plugin:

function loadOtherPluginsFirst() {
  $folders = glob( kirby()->roots()->plugins() . DS . '*', GLOB_ONLYDIR );

  if( ! empty( $folders ) ) {
    foreach( $folders as $folder ) {
      $name = pathinfo($folder, PATHINFO_FILENAME);

      if( $name != 'my-plugin') {
          kirby()->plugin( $name );

When doing the above it loads every plugin except your plugin first, which means your plugin will load last. Because a plugin will only be loaded once you don’t need to worry about that the plugins will load mulitple times, they will only be loaded once.

That means you can still have your own structure:


The only pitfall I see is that if there are many plugins with this function they will compete of which of them will run last.

Feedback appreciated.

Thanks for the word! :slight_smile: