WIP: Trying to add RSS feed, ending up in restructure
First things first: The work turned out to be much more than I expected, so I won't have the time to finish it. Nevertheless, I thought that I should still post the results of about a week of full-time work here.
Concept
Migrate the Blog as an easy, small part with little context to Symfony Flex first. Then add other modules one after each other.
State
Usage of Symfony controllers for the blog:
- A new entry point
index2.php
is created (copied fromrestApi.php
) - A
BaseController
class is created which still usesPageHelper
to set template variables - Route annotations are enabled
- Default format is left unconfigured in router (REST api also works with this configuration)
- Improve
services.yml
NOTE The patch at the end of this post must be applied to the foodsharing image (nginx).
Bug
I noticed that many things didn't work as expected. I identified the root cause was in conig/services.yml
:
Twig:
alias: Twig\Environment
Removing this (together with most of the Twig
declarations in the same file) allowed many things to work automatically as expected. This change is not included in my commit since I didn't know the effect on other parts of the application.
Suggested continuation (RSS)
- The blog database table should be migrated to using Doctrine.
- Add and configure RSS bundle
Suggested continuation (global)
Disclaimer: Yes I read #68 (closed), and I think it is good work, but maybe one can skip this intermediate step and go directly to using Symfony everywhere.
As a guide, one could use Upgrading Existing Applications to Symfony Flex (It is really good and helped me a lot!). As an intermediate step, I would let the two systems sit aside. Migrate one module after each other separately. When everything is migrated, the Twig templates can be migrated as a last step and the BaseController.php
I introduced could be modified accordingly.
Some specific tasks to start right now:
- All tests in the master branch must always succeed! Otherwise it is impossible for newcomers to notice if any new failures are introduced!
- Add more tests to notice regressions immediately.
- I suggest renaming the
FoodsharingKernel
to justKernel
such that more framework code can be used directly. This should be done as early as possible to reduce the number of places where changes must happen. - Migrate to using Dotenv for configuration is pretty independent of the other tasks.
- Move public root to
./public
folder requires probably not many places to change (probably just a few Helper classes). Add all public resources like images there.
web container image accompanying this MR
Patch fordiff --git a/web/app.conf b/web/app.conf
index 7b94453..a5f8e25 100644
--- a/web/app.conf
+++ b/web/app.conf
@@ -62,6 +62,10 @@ server {
try_files $uri /restApi.php$is_args$args;
}
+ location /blog {
+ try_files $uri /index2.php$is_args$args;
+ }
+
location ~ ^/(js|css|images|data|tmp|img|(cache/searchindex))/ {
allow all;
try_files $uri =404;
diff --git a/web/foodsharing.conf b/web/foodsharing.conf
index c6e7d3f..15a7222 100644
--- a/web/foodsharing.conf
+++ b/web/foodsharing.conf
@@ -58,14 +58,6 @@ location ^~ /karte {
try_files $uri $uri/ /index.php?page=map&uri=$uri;
}
-location ^~ /news {
- try_files $uri $uri/ /index.php?page=blog&uri=$uri;
-}
-
-location ~ "^/blog/([0-9]+)$" {
- try_files $uri $uri/ /index.php?page=blog&sub=read&id=$1;
-}
-
location ^~ /mach-mit {
try_files $uri $uri/ /index.php?page=join&uri=$uri;
}
@@ -76,4 +68,4 @@ location ^~ /fairteiler {
location ^~ /essenskoerbe {
try_files $uri $uri/ /index.php?page=basket&uri=$uri;
-}
\ No newline at end of file
+}