T
T
teodor7teodor72016-09-30 18:45:32
PHP
teodor7teodor7, 2016-09-30 18:45:32

What to use Autoload or require or namespace?

Explain looking at various frameworks, I can’t figure out why to use require if there is a namespace. There is also autoload. Tell me, the appearance of namespace did not solve the require problem? Just as far as I understood from PSR, require and namespace are not used in one file. Why else is autoload used in various frameworks?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
Cat Anton, 2016-09-30
@27cm

Tell me, the appearance of namespace did not solve the require problem?

No. The "require problem" was solved by the appearance of autoloading back when there were no namespaces.
Everything should be applied where it is needed:
1. To automatically load PHP files with classes or functions, use autoloader (composer), PSR and namespace.
2. To connect the autoloader, use require: require 'vendor/autoloader.php';
3. To connect, for example, a php file with a configuration, use include:$config = include 'config.php';

A
Ankhena, 2016-10-08
@Ankhena

collapsing margin

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question