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

前端 未结 5 620
野性不改
野性不改 2020-11-28 00:34

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.

5条回答
  •  情话喂你
    2020-11-28 01:20

    Even when I tried but Composer is a mess. Sadly, it's the only alternative.of the market.
    Why is a mess?.
    The Composer's autocomplete works fine if you are in control of the code. However, if you are importing a different project, you find yourself with lots of styles and ways to create folders. For example, some projects are /company/src/class.php while others are company/class.php and others are company/src/class/class.php

    I created a library that solves it:

    https://github.com/EFTEC/AutoLoadOne (it's free, MIT).

    It generates an autoinclude by scanning all the classes of a folder, so it works in every case (psr-0 psr-4, classes without namespace, file with multiple classes..

    edit: And again, downvoted without any reason. ;-)

提交回复
热议问题