silverstripe-dashboard icon indicating copy to clipboard operation
silverstripe-dashboard copied to clipboard

Adding autoloading

Open LABCAT opened this issue 4 years ago • 2 comments

LABCAT avatar Jul 07 '20 05:07 LABCAT

I think the namespace changes will break backwards compatibility. So should this change be included in the next major version, 5.0? Anyway, the namespace changes are good, so I'm not against them. :)

My second question is that as SilverStripe has it's own autoloading mechanism, why would we need composer to handle the autoloading of this module? I understand composer's autoloader is needed for libraries that are not SilverStripe modules, but what are the benefits in a case like this module? I'm only asking this because I'm not very familiar with composer's autoload. I use composer a lot but have never paid much attention to the autoloading stuff.

Taitava avatar Jul 07 '20 06:07 Taitava

"I think the namespace changes will break backwards compatibility. So should this change be included in the next major version, 5.0?'

Yes, it would cause minor issues for other products and I just realized I haven't updated the use statements in the module (doing so would ensure the module is backwards compatible).

" I understand composer's autoloader is needed for libraries that are not SilverStripe modules, but what are the benefits in a case like this module?"

The main benefit is that you can use php stan on projects that extend the module in some way. For example the following module: https://github.com/sunnysideup/silverstripe-ecommerce_dashboard

Extends this one and has autoloading. We want to run php-stan on the module but it doesn't work because requires auto loading to be configured on any module that it extends.

LABCAT avatar Jul 08 '20 02:07 LABCAT