A
A
Alex1222016-11-19 22:15:33
Yii
Alex122, 2016-11-19 22:15:33

How does file auto-upload work in PHP?

Hello! Now I'm implementing class autoloading for the project. I use the spl_autoload_register function to load classes. I have a following question. For example, in the yii2 framework, I can create an arbitrary folder in the project, a file in this folder, and describe the class in this file. Next, I write a namespace in this class and it becomes available from the entire project. Suppose all ALREADY created folders in the project, I can sort through the spl_autoload_register function, but what should I do if the programmer will CREATE folders himself in the future? Should I parse folders throughout the project to find the class file I need? How can I implement the same thing that already exists, for example, in yii2 and do it elegantly?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DevMan, 2016-11-19
@Alex122

yes, parse all folders.
only not with every call, but with a special command like "build / manifest", which will scan the necessary folders, build a "map" and save it to the cache.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question