Reputation: 319
I know how to load my classes properly using composer, and how to name and organize folder/files/class for PSR-4
However, I'm having a use case I've never faced before, and can't seem to find a proper answer here or anywhere about the (or at least one of the) right way to do it
I have namespaced function, without any classes, in my composer library and I would like to make them accessible
namespace Foo\Bar;
function baz() {};
How am I supposed to organize this on disk, and how do I configure/load it in composer ? In a way that doesn't scream "I hacked at it until something kind of did what I wanted for some reason"
EDIT:
I know I could potentially use static function in a class and that's probably where I will go if I can't find any better, but that's really like sidestepping the issue with. They're functions, not static function of a class.
About the possible duplicate given in comment: I know I can force-require the file to make the function available, the question is how do I do it in a way that the file isn't always required, but only where the user want to use it.
Upvotes: 0
Views: 88