setPackage and addPackage

What is the difference between setPackage and addPackage ?

I’ve only seen addPackage() being used.

Looking at the code, setPackage() ifself calls the function addPackage().

This might help: Understanding addPackage, loadClass and getService | MODX, though it doesn’t deal with setPackage(), which I also have never heard of. :wink:

setPackage calls addPackage and then sets the “primary” package prefix to use when loadClass is called, whereas addPackage just adds a package to the array of packages to search through. It is irrelevant in xPDO/MODX 3.x as class namespaces and autoloading take precedence over the deprecated loadClass strategy.