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

Add DI to Moodle

XMLWordPrintable

      As part of the Web Service work we're hoping to use Dependency Injection to simplify routing.

      This issue is about adding that DI.

      The proposal is to use php-di (https://php-di.org) and to configure it via a \core\container with auto-wiring enabled.

      Hooks can be registered to add additional non-auto-wired classes.

      The presence of DI in Moodle will allow the router proposed for use in the Web Services changes to add any required dependencies with minimal configuration.

      DI will also be of great value for simplification of unit tests, especially with regards tooling such as Guzzle. An example of this usage can be found here: https://github.com/andrewnicols/moodle/blob/6a26ba5ec82c1a1250cd3ee2fa972fdd6f2ebd39/lib/tests/container_test.php#L70-L109

            dobedobedoh Andrew Lyons
            dobedobedoh Andrew Lyons
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

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