Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-60140

Introduce a front controller



    • New Feature
    • Resolution: Won't Do
    • Minor
    • None
    • Future Dev
    • General
    • None


      If you don't know what a front controller pattern is, start for example with these:

      Front controller would introduce many benefits:

      • Decreases code duplication
      • Increases flexibility
      • Increases security as the front controller can take care of tasks that a plugin developer may forget to implement individually to each individual plugin file
      • Allows clean URLs (e.g. https://www.site.org/user/profile/123 instead of https://www.site.org/user/profile.php?id=123
      • Allows centralized dependency management (e.g. autoload.php of Composer can be included in it)
      • Attracts professional developers to Moodle

      There is no reason why the new pattern couldn't work side by side with the old way. Web servers can be configured to check whether an URL points to an actual file. If this is the case, the file can be called directly. However, if no file is found, the request would be handled by the front controller.

      An example:

      The file used as a front controller is usually index.php located at the root directory of the project. Currently that file is used to serve Moodle's front page, so the only change to existing code at the very beginning would be to move that code somewhere else. (Maybe the front page could be the first page to be converted to be served through front controller?)

      I won't yet go into details about the actual implementation, as the needed tasks and discussions should most likely belong to their own separate issues.


        Issue Links



              Unassigned Unassigned
              juho.jaakkola Juho Jaakkola
              6 Vote for this issue
              9 Start watching this issue




                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.