我想安装第 3 方库,搜索后我尝试将其包含在app/autolad.php 中:
loader->registerNamespace('libMyLib', __DIR__.'/vendor/mylib/libmylib');
这会引发错误:
Call to undefined method Composer\Autoload\ClassLoader::registerNamespace()
哪个搜索看起来像 Symfony2 中包含的 ClassLoader 与组件 ClassLoader不同,您必须安装此组件才能使用此方法包含第三方库。
所以,我尝试按照神秘的说明安装它,看起来我需要安装Composer(我在 Windows 下),用这两行更新我的 composer.json (我根据packagist组成了版本号):
"symfony/finder": "2.2.*",
"symfony/class-loader": "2.4.*",
并且composer install
在我的命令行中执行(就在 symfony 文件夹下),我没有发生任何事情,我收到这条消息:
Loading composer repositories with package information
Installing dependencies from lock file
Warning: The lock file is not up to date with the latest changes in composer.json.
You may be getting outdated dependencies. Run update to update them.
Nothing to install or update
Generating autoload files
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap handling the post-install-cmd event terminated with an exception
[RuntimeException] An error occurred when generating the bootstrap file.
所以我比开始时更迷茫;如何包含第 3 方库?如何安装组件?
谢谢