Routes in plugins don't work because extend() in trait AppPlugins is called twice - the second time probably not really on purpose since the call stack looks like this:
(the class App constructor wants to "handle errors", that one wants to check if the debug config has been set, but by checking that, the options function loads the config files AND also calls extend)
Calling extend() twice breaks stuff because it uses array_replace_recursive() which doesn't really work for the array structure used for routes extensions:
This means some routes in your plugin might work, as long as you declare more routes there than in your config file. E.g. if you have 3 routes in your config file, the fourth route in your plugin will work
Kirby\Cms\App->options() probably shouldn't have side effects (like calling extend) and adding the routes from config.php should probably be done explicitly in App.
to make array_replace_recursive() work with routes, each route should have a unique key in the array (could be based on its pattern):
Routes in plugins don't work because
extend()
intrait AppPlugins
is called twice - the second time probably not really on purpose since the call stack looks like this:(the
class App
constructor wants to "handle errors", that one wants to check if thedebug
config has been set, but by checking that, theoptions
function loads the config files AND also callsextend
)Calling
extend()
twice breaks stuff because it usesarray_replace_recursive()
which doesn't really work for the array structure used for routes extensions:in pseudocode:
This means some routes in your plugin might work, as long as you declare more routes there than in your config file. E.g. if you have 3 routes in your config file, the fourth route in your plugin will work
Kirby\Cms\App->options()
probably shouldn't have side effects (like calling extend) and adding the routes from config.php should probably be done explicitly inApp
.to make array_replace_recursive() work with routes, each route should have a unique key in the array (could be based on its pattern):