spatie / wordpress-ray

Debug with Ray to fix problems faster in WordPress apps
https://myray.app
MIT License
73 stars 14 forks source link

Using Jetpack autoloader instead of Imposter. #33

Closed jeffreyvr closed 3 years ago

jeffreyvr commented 3 years ago

I realise this might be more of a discussion point, but I figured I'd create a PR none the less.

In an attempt to get rid of having to run this command: 'sed -i -e 's/'\''Symfony/'\''Spatie\\WordPressRay\\Symfony/g' ./vendor/symfony/var-dumper/Cloner/AbstractCloner.php'

I tried out Mozart but ran into this issue https://github.com/coenjacobs/mozart/issues/66 which is something the maintainers are discussing on how to solve. This issue resulted in the helpers.php not being loaded among some other packages files.

Then I stumbled upon Jetpack Autoloader from Automattic (company behind wordpress.com), a custom autoloader generator that uses a classmap to always load the latest version of a class.

The question is if this, using the latest versions of a class, is good enough - or that prefixed classes are preferred. If the latter is preferred, I think Imposter might be the better choice.

Using the Jetpack autoloader the prefixes are no longer needed and additionally, https://github.com/spatie/wordpress-ray/issues/8 is solved.

I wonder what you think @freekmurze.

freekmurze commented 3 years ago

I don't have a real preference. Whatever works best for WordPress is good for me. If this works just as well as the imposter and we can't lose that ugly sed then I would have no problems using the Jetpack solution.

jeffreyvr commented 3 years ago

I'm in doubt about this. I guess it wouldn't work just as well unfortunately.

Because prefixing means you will always know for certain you'll be dealing with the correct version of a package. With the Jetpack Autoloader, you'll be using the latest version of a class - which could theoretically mean you end up with a version you don't want to use.

On the other hand, it is used by the Jetpack plugin which is active on 5+ million sites...

I've seen some reports of the Jetpack autoloader causing issues:

https://wordpress.org/support/topic/fatal-error-plugin-activations/ https://github.com/Automattic/jetpack/issues/17221

Close for now?