Skip to content

Convert entry points to Symfony controllers

Fridtjof requested to merge fridtjof/controller-entrypoints into master

What does this MR do?

This MR moves all code from the application entry points (index.php, xhr.php, xhrapp.php) to new Symfony controllers. In the process, I was able to simplify the code a bit because we can use DI in these controllers :).

Now that all code is essentially wrapped in these controllers, features like the Symfony profiler (!1580 (merged)) will be much easier to use (e.g. the Web Debug toolbar should show up once that's merged, because it is injected after a controller returns its Response). Also, it will work for all parts of the website now.

Most importantly, this is groundwork for slowly porting the website to Symfony controllers, and modernizing our routing (with /modern/style/urls)

How confident are you it won't break things if deployed?

Relatively confident - I took care to keep all behavior as it was before. I had to implement a slight hack for xhr.php and xhrapp.php to make them work with symfony's routing - doing it "properly" (i.e. removing xhr.php, xhrapp.php and putting all requests through index.php instead - Symfony will pick the right controller depending on the path itself then) will fairly certainly need adjustments in the nginx config. Also, I added many Symfony routes to handle some special URIs - see config/routes/special.yaml for details.

I'll post another MR to merge all entry points into one after this one is merged, which should be done together with the admins, so it does not break beta or (worse) production. (This is the proper way that lets us avoid the hack I mentioned)

How to test

Steps a reviewer can take to verify that this MR does what it says it does e.g.

  1. Checkout branch locally
  2. check different types of requests on different entry points, and with different modes of response handling (some controllers might use echo, some might return a string, some even already use a Response object)

Also, someone with more profiling and/or influxdb knowledge should take a look at how much this affects loading times (the request is now passing through lots of extra (symfony) code before ending up in our controllers, after all). I left the old entry points in with an _old suffix for this, they should still work - just exchange them with the new ones.

Checklist

  • no test necessary, this is a low level change which would break many other tests if it went wrong
  • no unrelated changes
  • asked someone for a code review
  • added an entry to CHANGELOG.md (description, merge request link, username(s))
  • Once your MR has been merged, you are responsible to update the #foodsharing-beta Slack channel about what has been changed here. They will test your work in different browsers, roles or other settings
  • remove WIP after approval, and delete index_old.php, xhr_old.php, xhrapp_old.php, lib/inc.php before merging
Edited by Fridtjof

Merge request reports