Page MenuHomePhabricator

Prepare migration of FundraisingFrontend from Silex to Symfony
Closed, ResolvedPublic


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


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, 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.
  • Replace accessing $app['session'] with if( $request->hasSession() $session = $request->getSession() else { $session = new Session(); $request->setSession($session);}
  • 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 BucketSelectionServiceProvider calls with event handling services. See slide 25ff
  • Replace $app->run with request and kernel initialization. See slide 38
  • Update Symfony dependencies from 3.x to 5.x

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. 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.

Further improvements after the transition

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. After switching to Symfony, use cases and presenters should be injected into the controllers, putting the methods of FunFunFactory as factory methods in the Symfony dependency injection file.

To be discussed

The following sections are suggestions that still need to be discussed and evaluated

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".

Event Timeline

gabriel-wmde claimed this task.

Epic is resolved, future improvements tracked in T265462: Use more Symfony features