Answer the question
In order to leave comments, you need to log in
Is it correct to use Singleton for db class and templating engine?
Good day. I decided to "ride" a little for practice and write a class for working with the database, as well as a small template engine. Googling, I saw that some people write such classes using a singleton. As I understand it, in order to access a single instance of an object from any corner of the application. Do I need to go this way and if not, advise which design patterns to use / not use for these purposes.
Answer the question
In order to leave comments, you need to log in
No.
Read about DI .
Why everything else is bad:
github.com/codedokode/pasta/blob/master/arch/di.md
PHP implementations:
github.com/ziadoz/awesome-php#dependency-injection .
Is it correct to use Singleton for db class and templating engine?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question