How PSR-4 encourages you to write better code.

I wanted to write a module with a views plugin.
This is one single class. Do we need PSR-4 for that? (*)

Looking back, I can say: The question was misleading.
No, I don't necessarily need PSR-4 for one single class. But once I had it in place, I quickly noticed how I could split big parts of the logic out of the views plugin, into a separate class. Quite a healthy thing to do.
Without PSR-4, I would have hesitated to introduce another class.

(*) In Drupal 7, PSR-4 is not built-in. You need something like xautoload.

Add new comment