Why register stuff with set that can be set without it?

In the new version (2.3) it’s possible to register a route with set:

https://getkirby.com/docs/developer-guide/plugins/registry

What is the benefit of register a route instead of just including a file with this inside a plugin?

kirby()->routes(array(
	array()
));

I have the same question for these types as well:

controller
hook
page::method
pages::method
file::method
files::method
page::model
tag

All the above can be set in a plugin without register them with set.

I added it to unify the syntax. A route is also a kind of extension, so I think it makes sense to offer the same way of registering it.

2 Likes

Just out of curiosity: how do I register a route with the new syntax exactly? Also with setting get/post methods? Is it:

$kirby->set('route', '/my/route/(:any)', function($uid){ … });

Besides that I think it makes sense to have one syntax – of course there are several ways to Rome, but if we all follow one, we can better help each other, be it pros or newbies :wink:

The syntax is very similar to the old one:

$kirby->set('route', array(
  'pattern' => '/my/route/(:any)',
  'method'  => 'GET',
  'action'  => function($uid) { … }
));
2 Likes

Okay, I see. Thank you!