What Are the Differences Between PSR-0 and PSR-4?

Recently I’ve read about namespaces and how they are beneficial. I’m currently creating a project in Laravel and trying to move from class map autoloading to namespacing. However, I can’t seem to grasp what the actual difference is between PSR-0 and PSR-4.

Some resources that I’ve read are…

  • Battle of the Autoloaders
  • Laracasts PSR-4 autoloading
  • PSR-0
  • PSR-4

What I understand:

  • PSR-4 does not convert underscores to directory separators
  • Certain specific rules of composer cause the directory structure to become complex which in turn makes PSR-0 namespacing verbose and thus PSR-4 was created

Examples explaining the difference would be appreciated.

5 Answers
5

Leave a Comment