\documentclass{article}
\usepackage{ulem}
\pagestyle{headings}
\begin{document}
\part{Bootstrapping an environment}
Horde's registry and bootstrapping predates composer, composer autoloader and most modern conventions. It is not helped by being super flexible in almost every aspect.\newline
Bootstrapping is the order in which (a necessary part of) the Horde application environment is set up before actually running useful code. The current process is hard to understand and reason about.\newline
With modern standards and concepts, a basic service or app need not carry around baggage from assumptions that may be entire irrelevant.

For example, the horde base app

\section{H5/Classic}
Not necessarily in that order. Even getting the order right is non-trivial.

- Calling the core from the page, service endpoint or CLI\newline
- setting up preliminary autoloading\newline
- Setting up some fundamental constants, including guessing some paths.\newline
- Lots of chicken/egg things\newline
- setting up a preliminary (opinionated) selection of Dependency Injection keys for the Horde\\Injector DI\newline
- setting up all sorts of scary globals\newline
- finding installed applications\newline
- finding config for installed applications\newline
- finding out if or if not snippets matching the current domain vhost should be applied\newline
- Setting up even more autoloading for the current app\newline
- Setting up filesystem locations and web-visible paths (possibly domains, too) for apps and the horde base app, themes, javascript, templates \ldots \newline
- Session handling, based on config\newline
- determine if the current session is administrative or has a certain permission\newline
- Language handling\newline
- Setting up fundamental services like auth, logging\newline
- Everything happens live on request

\section{Standalone/Web}
Three stages:

\subsection{Early stage }
- Web server calls entrypoint.\newline
- Composer autoloader first. One load to rule them all.\newline
- Feed the DI with the bare minimum for routing purposes. (Less is better)\newline
- Load cached list of relevant apps/services that expose routes. If it does not exist, assemble it.\newline
- some primitive early error handling

\subsection{Routing stage}
- Load routes\newline
- Assemble request object\newline
- match request with routes\newline
- call stack associated with route\newline
- Perform PSR7/15 dance\newline
- handle route-not-found / default route

\subsection{Middleware/Controller stage}
- authentication, if they want it\newline
- permission handling, if they want it\newline
- prefs handling, if they want it\newline
- login to backing services, if they want it\newline
- handle any errors

\section{Modern/CLI}
TBD

\subsection{Random considerations}
- Apps (and services) are basically groups of routes that share a codebase and a subdomain + webroot combination.\newline
- Something standalone would not need registry, but would need (top level) routing.\newline
- Is Registry is just an added value top layer router that houses per-app / per-service sub routers?\newline
- Registry Config MAY depend on host of the request. To keep it lean, vhost is "always on". Parsing a config to find out if you should load a file (or ignore if missing) is always more expensive than just doing it.\newline
- Registry Config determines webroots for apps, Routes depend on it. Setting up registry should be fast with as few side effects as possible. It should not imply heavy lifting, setting up DB/IMAP or other expensive connections.\newline
- But we do not need heavy weight app init upfront.\newline
- For routing setup, we do not care if the app in question is disabled, inaccessible for the current credentials or anything. This should be handled by some middleware.\newline
- Each app/service has its endpoint, identifying a first routing level and at least some registry-defined routes for URI generation (js, themes, templates, appwebroot)\newline
- We want to be able to generate routes towards other apps inside this installation.\newline
- nested route groups can be resolved to one single set of combined routes.\newline
- nested route groups can have default middleware stacks at each level. These can be merged to a single middleware stack, including the route's handler, middleware or stack\newline
- nested route groups can have a catchall on each level.\newline
- How to attach / autogenerate useful API docs (like openapi) from routing information?\newline
- Are verbs part of the routing or should they be filtered by a middleware?\newline
- URI parameter constraints.\newline
- Collecting the routes into one consumable RoutesCollection\footnote{http://example.com/index.php?page=RoutesCollection} should be separate from consuming the RoutesCollection\footnote{http://example.com/index.php?page=RoutesCollection}. Collect at install/config time and save the result. \newline
- Routes Matching should produce a MatchedRoute\footnote{http://example.com/index.php?page=MatchedRoute} exposing useful information but should not call/dispatch the resulting stack.\newline
- The router must allow to pass through some information it is not interested in by itself or does not recognize

\end{document}
