Composer vs Symfony 2 autoloader

狂风中的少年 提交于 2019-12-21 07:58:07

问题


I'm starting to use Composer in a project, in which I historically had all the dependencies under version control.

This project currently uses the Symfony 2 autoloader. Because Composer comes with its own autoloading mechanism (vendor/autoload.php), that makes me wonder if I still need to use the Symfony ClassLoader.

I assume that I could just use the Composer autoloader to autoload my project classes as well:

$loader = require 'vendor/autoload.php';
$loader->add('MyProject', 'src');

Is there any drawback in using the Composer autoloader for the whole project?

Are there features the Symfony autoloader offers that I won't find in the Composer autoloader?


回答1:


You can just require the composer autoloader. The only feature it lacks is the ApcClassLoader which speeds things up with APC but introduces some complexity (you have to clear the cache when deploying). Using composer's -o flag (when installing or running dump-autoload) will give you a classmap one which is more or less equivalent to APC in terms of speed but without the complexity.



来源:https://stackoverflow.com/questions/13892614/composer-vs-symfony-2-autoloader

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!