Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#43979 closed feature request (duplicate)

PSR-4 Autoloader

Reported by: alicewondermiscreations's profile alicewondermiscreations Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Bootstrap/Load Keywords:
Focuses: Cc:

Description

WordPress really needs a PSR-4 autoloader.

With a PSR-4 autoloader, plugins and classes could require a namespaced class and it would load on demand.

This would solve #43898 because what I want there can be solved with a class, in fact I'm doing that now on three blogs running it as an mu-plugin - but mu-plugins can't be updated automatically, they can only manually updated.

Things like TGMPA that you find used in many plugins / themes could be loaded that way, instead of needing many copies in each plugin / theme that wants it.

A PSR-4 autoloader would give a way that a plugin or theme could use a third party API without needing to bundle the API itself.

I would suggest wp-content/wp-psr as the directory - with vendor/product directory structure inside, and PSR-4 class installer/updater similar to the plugin/theme installer/updater.

Some things in core could even likely be moved into it.

But anyway a PSR-4 autoloader would solve the issue of some things needing to be in mu-plugins for no other reasons than to make sure they are loaded, and could also be used to take some eye candy out of core that can be loaded that way.

A PSR-4 autoloader would be a single file and could work with every version of PHP that still received security fixes from upstream PHP.

Change History (2)

#2 @ocean90
7 years ago

  • Component changed from General to Bootstrap/Load
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed
  • Version trunk deleted

A proposal for an autoloader is already being tracked in #36335.

Note: See TracTickets for help on using tickets.