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 candidate for the migration is Symfony, as Silex uses Symfony components internally and we're using Twig and Doctrine, which are already the default templating and database abstraction solutions in Symfony. Also, the framework is modular, tested and has wide adoption and extensive documentation.
## 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 method's signature has type hints that those objects should be injected.
https://github.com/wmde/FundraisingFrontend/pull/1278 demonstrates how to move anonymous functions to controller classes. It also adds code 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
At the moment, the controllers expect the FunFunFactory as a parameter and get necessary use case and presenter classes out of it. That means 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.
When switching to Symfony, we should think about injecting the use cases and presenters into the controllers, putting the methods of FunFunFactory as factory methods in the Symfony dependency injection file.
Also, some of our implementations (e.g. `Routes::getNamedRouteUrls`) might be replaced by Symfony implementations.
#### 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. The steps from "Necessary refactoring steps" could be converted into tickets, the conversion of the routes into controllers could be split into three or four tickets - Donations, Memberships, Payment and "Other".