T
T
thorii2016-09-29 22:01:10
PHP
thorii, 2016-09-29 22:01:10

Do I need to spread class loaders into different classes to maintain the Single Responsibility Principle?

There is actually a class that configures the application (core.php). It sets encodings and declares global helper CONSTANTS. Is it possible to write autoload functions into it, or is it better to put them in separate classes? (spl_autoload)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
index0h, 2016-09-30
@index0h

Have you just been thrashed? In the yard 2016))
The Internet is full of articles "why global variables are evil."
PSR-4 + composer. Autoloading is a problem solved a long time ago, you should not invent an unnecessary bicycle for anyone (including you).

S
Sergey, 2016-09-30
Protko @Fesor

and declares global auxiliary variables.

about autoloading you have already been answered - use composer. And at the expense of global "auxiliary" variables - get rid of them. Use a dependency container or service locator to manage dependencies and system configuration.
Either learn how to make an isolated state - or just forget it and write procedurally like in the days of php4. There is nothing wrong with that, the vast majority do not even know that they have proceduralism with classes.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question