Support » Requests and Feedback » PSR-4 Autoloader

  • alicewondermiscreations


    create a directory called wp-content/psr4

    Withing that directory support the vendor/package infrastructure that PSR-4 needs.

    Then within core, have a PSR-4 autoloader that looks there.

    That way classes that are useful to more than plugin can simply require the class be installed there and the class will load when the plugin or theme wants it without the class needing to have a local copy wrapped in a if block to see if it exists.

    There would need to be a mechanism for plugins/themes to trigger the install of a class if it isn’t already there when the plugin/theme is installed.

    It would make a lot of things easier and could reduce plugin conflicts because different namespaces could be used for conflicting versions of classes.

    WP Core could even put some of its classes in there. Then a plugin that needs a custom version of something in core could have its custom version in a different namespace without conflicting with other plugins that want core’s behavior.

    PSR-4 autoloader is nice because you don’t have to put a class into mu-plugins to make sure its available to any plugin/theme that wants it.

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘PSR-4 Autoloader’ is closed to new replies.