ELI5: Routing in 5.7

Hey all

(ELI5 = Explain Like I'm Five)

I've just (literally, this week) started looking at Laravel and love it.

It got me wondering though, in our 5.7 routing file we don't say, have any listings for any of the dashboard pages.

Any heads up on why this is?


View Replies:
Mainio replied on at Permalink Reply
I think single pages (and normal pages) are using the "last call" router callback, i.e. the DispatcherRouteCallback (concrete/core/Routing/DispatcherRouteCallback.php).

These requests are searched straight from the DB from the PagePaths table as they used to be in the old concrete5. You can see this search from the Page model (concrete/core/Page/Page.php). Take a look at the Page::getFromRequest() method.

EDIT: Links to the relevant classes/methods:
ijessup replied on at Permalink Reply
I've run through the code, but I feel like I'm missing something.

I've figured out how to register additional package autoloader prefixes...
$symfonyLoader = new SymfonyClassloader();
$symfonyLoader->addPrefix(NAMESPACE_SEGMENT_VENDOR . '\\Package\\' . camelcase($this->getPackageHandle()) . '\\Core', DIR_PACKAGES . '/' . $this->getPackageHandle() . '/' . DIRNAME_CLASSES);
...but from a package's controller (or anywhere for that matter), how do we register a new route?

For example, "/ccm/system/search/files/submit" routes to the Files Search Controller's Submit function. This is evident in the ~\concrete\config\app.php file @ line 263. But how to we add to this list from within our packages - specifically in my case, from the package controller's on_start function?
Shotster replied on at Permalink Reply
> ...but from a package's controller (or anywhere for that matter),
> how do we register a new route?

Here are a couple threads on registering AJAX routes, but much of it should be applicable to non-AJAX routes as well. In short, use the Route facade to register your routes in the on_start() method of your package controller.