We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Is it a good thing to use composer instead of the built-in Autoloader

As i said in title, is it a good idea to don't use the built-in autoloader and to use composer instead for loading models and controllers ?

Does it imply performances fallout ?



98.9k
Accepted
answer
edited May '16

Actually, an auto-loader (the process of trying to realize which path is a class name located at) does not represent a major impact in performance, you can freely use the one provided by composer without decrease the performance. The bootleneck here is read files or read a large amount of files, because read files from the filesystem is expensive, in that case, you can improve the performance by using a opcode cache such as APC or ZendOptimzer.

Also, take into consideration that there are strategies to autoload files that are more performance friendly than others,

For example, in Phalcon\Loader, the directories strategy (more unnecessary stats) is the slower one compared with the namespaces strategy (less stats), the class-map based autoloading is the faster but is less flexible. You can see a detailed explanation of that in the docs: https://docs.phalcon.io/en/latest/reference/loader.html