Spatie are a well known company, who specialise in Open Source packages. This means the package is updated more often and bugs will be fixed more quickly. For example, the last commit in hpierce1102/classfinder was June 18, 2023, whereas the last commit in spatie/php-structure-discoverer was today.
There are a few other benefits of the Spatie package:
It doesn't rely on the composer.json to load files, meaning we no longer have to deploy that.
There's no hidden logic; we can see exactly how the classes are being loaded now and what constraints are being put on them.
We can conditionally cache the class loader, giving it a considerable performance boost on production/staging.
Old Class Loader
New Class Loader
Additionally, during the refactor, I eliminated all the hardcoded strings and awkward configurations needed to get the classloader working. It should now be plug-and-play.
One downside of this change is that it only supports PHP 8.1 upwards, though since every version pre-8.1 is End of Life, I think that's a fair tradeoff, https://www.php.net/supported-versions.php.
How to test the Change
Ensure all classes are still loading and test suite is passing.
Changelog Entry
Changed - Class loading swapped out for a newer, more performant library.
Description of the Change
This PR updates the class autoloader from using https://gitlab.com/hpierce1102/ClassFinder/ to using https://github.com/spatie/php-structure-discoverer and adds unit tests to ensure it's working as expected.
Spatie are a well known company, who specialise in Open Source packages. This means the package is updated more often and bugs will be fixed more quickly. For example, the last commit in
hpierce1102/classfinder
was June 18, 2023, whereas the last commit inspatie/php-structure-discoverer
was today.There are a few other benefits of the Spatie package:
composer.json
to load files, meaning we no longer have to deploy that.Old Class Loader
New Class Loader
Additionally, during the refactor, I eliminated all the hardcoded strings and awkward configurations needed to get the classloader working. It should now be plug-and-play.
One downside of this change is that it only supports PHP 8.1 upwards, though since every version pre-8.1 is End of Life, I think that's a fair tradeoff, https://www.php.net/supported-versions.php.
How to test the Change
Ensure all classes are still loading and test suite is passing.
Changelog Entry
Credits
Props @darylldoyle
Checklist: