As a **developer**,
**I want** to be sure I can find support and documentation for the libraries I use,
**so that** I can develop quickly and with confidence,
**and** rest assured that security issues are fixed continually
## Context
The Silex framework we're using in the FundraisingFrontend application is deemed End-Of-Life in June 2018. This is not a reason for panic, as we're mostly using only the routing and dependency injection features of it and don't foresee the need for more features and development in that area. The security aspect is also negligible, as the HTTP and DIC components underlying the framework (Symfony HTTP Kernel and Pimple) are still maintained. However, in the long term, those components will also become End-Of-Life and we need to migrate the "HTTP Framework" part of the application to something else. The most likely candiate for the migration is Symfony, as Silex uses Symfony components internally and we're using Twig and Doctrine, which are a good for for Symfony.
## Necessary refactoring steps.
As outlined in the presentation at https://slidr.io/derrabus/the-silex-sunset, there are four places in the application that need to be touched:
- Replace calls to methods on `$app->json` with constructing new JSON `Response` classes.
- Move anonymous route functions and `RouteHandlers` into controller classes, reference them in routes.php.
- Replace `before`, `after` and `error` calls with event handling services. See slide 25ff
- Replace `$app->run` with request and kernel initialization. See slide 38
These refactoring steps don't need to be done in one fell swoop, we can do them whenever we touch routes.
### Moving anonymous functions from routes.php to controller classes
Controller classes are plain PHP classes that are instantiated automatically by Silex when a route is called. For every route, a public class method ("controller action") is called. Silex will inject the Request object in the method, if the methods signature has type hints that those objects should be injected.
https://github.com/wmde/FundraisingFrontend/pull/1278 demonstrates how to move annymous functions to controller classes. It also adds code to to automatically inject the FunFunFactory, the central factory for the presentation-independent code, into the controller action methods, when the method signature hints that FunFunFactory is needed.
## To be discussed
The following sections are suggestions that still need to be discussed and evaluated
##### Dependency Injection
The automatic injection of the FunFunFactory makes it easy to convert all anonymous route functions to controllers. However, for the controllers themselves, the FunFunFactory exposes a public interface that technically is too broad. Ideally, each controller would be a wrapper around one use case, that automatically gets injected. This can be done in a similar fashion as it is done in `FundraisingFactoryServiceProvider`. Presenters could be built and injected with a separate Factory, to make FunFunFactory the central building point for use case classes only.
#### Structuring controllers
We need to discuss how we structure the `Controllers` directory. Possible solutions:
* Each anonymous function gets its own controller, with an `index` method
* Have one controller per bounded context
* both of the above, with namespaces for each bounded context.
* something else
#### Splitting tasks into tickets
If this epic becomes a story, we should split it into individual tickets.