When I run this in config.php
:
kirby()->plugin('test');
Then that plugin loads and then the other plugins don’t load at all. Is it expected behavior?
My intention was to load this plugin first and let the rest load after that. Should I use GLOB to get all the plugin paths or is there a better way to load the rest of the plugins?
I can’t load this plugin from another plugin in this case because there is no other plugin.
It’s not expected behavior but what you are trying to do is just not intended. Why do you need to load the plugin in config.php
? Maybe we can find a more robust solution.
I have a plugin that uses hooks which I need to load first before hooks from all other plugins.
I could rename it to “aaa” but that’s not so nice.
I’m doing it like Jeff Bezos: Why do the hooks need to be loaded first?
I’m doing it like Jeff Bezos: Why do the hooks need to be loaded first?
By always answer with a question?
Taaadaa!
Kirby Hooks Debugger
There are two main problems with hook errors in the panel.
The panel hangs.
No useful information about the error is displayed.
This plugin presents a useful error message.
[image]
[image]
In the future I hope there will be a built in solution, but until then this plugin might be useful.
1. Install
Kirby CLI
Run this command:
kirby plugin:install jenstornell/kirby-hooks-debugger
Manually
Add the folder kirby-hooks-debugger into /site/plugins/.
2. Usage
1. Bluep…
I hope to find a better solution for the plugin to be loaded first.
Must be loaded first
Kirby Hooks Debugger needs to load before any other plugin that uses hooks in order to work. There are at least two ways to do that:
Alternative 1 - Rename the plugin
Rename the folder kirby-hooks-debugger
to aaa
and the file kirby-hooks-debugger.php
to aaa.php
.
Alternative 2 - Load the Kirby Hooks Debugger plugin from your plugin
If you are building a plugin you can add this line to force load the Kirby Hooks Debugger plugin.
Hm, I’d register the shutdown function in the plugin file instead of in the hook. Disadvantage: You don’t get the name of the hook. Advantage: It just works™.
Only thing you need to be careful about is to register the shutdown function only if the Panel is loaded (function_exists('panel')
).
No, it’s called the “Five Whys”.
Disadvantage: You don’t get the name of the hook. Advantage: It just works™.
Yes, maybe I’ll go with simplicity. Hopefully it’s not that hard to figure out which hook is fired.
No, it’s called the “Five Whys”.
Alright, I’ve read about the five whys now. Interesting.
I’ve also been thinking that with too many questions, it will always end up in biology, physics, psychology or space.
Why do the hooks need to be loaded first?
Because the plugin will work as expected.
Why do you want the plugin to work?
Because it helps me develop other things.
Why do you develop other things?
Because I enjoy it.
Why do you enjoy it?
My brain tells me to.
Why does you brain tell you to.
It’s a part of my survival instinct to develop stuff.
Why do you need to survive?
To make the earth a better place.
Why do you need the earth to be a good place?
…
A little off topic again, I know…
2 Likes
Hahah, your conversations sometimes remind me of the two old guys from the Muppets. Pure gold!
Haha!
The only thing I rembember from that show is a frog named Kirby (or was it Kermit)?
Oh, I also remember the cookie monster. I’m not too fond of cookies, except for persisted ones.
I thought you’d remember the Swedish Chef
2 Likes