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

POLICY: Allow PSR-4 namespacing in core

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Won't Do
    • Icon: Minor Minor
    • None
    • 3.3
    • Libraries, Policy
    • MOODLE_33_STABLE

      Programming is hard. In moodle we want to lower the barrier for entry to ensure

      But as time goes on 1999 PHP practices are getting more and more outdated. They seem "simple" to us because they are old. Not because they actually are simple.

      So what can we do to lower the barrier for entry without doing things in an outdated, confusing way? Follow standards.

      To increase the understandability of moodle, we should switch to following PHP Standard Recommendations rather than shoe horning our own approach.

      Already more and more is being moved out to the classes folder, which is more confusing for external developers than if they were in the folder from their namespace.

      Example

      \tool_monitor\output\managesubs\rules
      admin/tool/monitor/classes/output/managesubs/rules.php

      Could be

      \Moodle\admin\tool\monitor\output\managesubs\rules
      admin/tool/monitor/output/managesubs/rules.php

      (just a bad example to give an idea. Obviously we will not be moving old classes - certainly not at first.)

      We have PSR-4 in core already, so this is really just a policy issue. I propose a gradual transition

      1. Modify policy to allow new classes to be PSR-4 based. Add Moodle to psr4namespaces to support it
      2. Modify policy so that all new components must be based on PSR-4
      3. Modify policy so that all new classes must be based on PSR-4 (caveat: if it's a subclass or closely tied to an existing class that is in

      Are we really going to keep the legacy /classes/ folder forever in moodle?

      Take change slow, sure, but let's not drag ourselves into obscurity and alienate developers by clinging to the past.

      Generally, more and more open source projects are moving towards PSR (reference)

            Unassigned Unassigned
            johno John Okely
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

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