Jump to content

ways to prevent singletonitis


koen

Recommended Posts

Since PHP is stateless it seems like a lot of classes can/should be made a singleton if you don't want to use globals.

 

eg classes user, acl, database, pluginhandler, security, settings, ...

 

Every of these seem to be in need of access anywhere in the script. That means passing instances everywhere or using some form of singleton. Or maybe there's more than I currently know. What are best practices in such cases?

Link to comment
https://forums.phpfreaks.com/topic/77722-ways-to-prevent-singletonitis/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.