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
- Modify policy to allow new classes to be PSR-4 based. Add Moodle to psr4namespaces to support it
- Modify policy so that all new components must be based on PSR-4
- 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)
- will help resolve
-
MDL-59684 Allow plugins to specify PSR-4 namespaces
- Closed