Breaking: Removal of PSR-0 class loader in Nextcloud 27

Hello app devs,

Here’s a heads-up for the maintainers of apps that still use class file names following the deprecated PSR-0 standard.

What will change?

Until Nextcloud 26 PSR-0 files will still be loaded by default. With 27 apps have to finally upgrade to PSR-4 or ship their own class loader. We highly recommend PSR-4 for better performance.

How do I adjust my app?

If you have a class \OCA\MyApp\FooBar at myapp/foobar.php then rename and move the file to lib/FooBar. The file name must match the class name. The namespace after \OCA\MyApp must match the directory structure inside lib.
Another famous example is myapp/appinfo/application.php. That file should be migrated to lib/AppInfo/Application.php.

Resources

Ref Upgrade to Nextcloud 26 — Nextcloud latest Developer Manual latest documentation
Ref PSR-4: Autoloader - PHP-FIG
Ref https://github.com/nextcloud/server/pull/36114

3 Likes