Reputation: 2773
I want to install a 3rd party library and after searching I tryed to include this in app/autolad.php:
loader->registerNamespace('libMyLib', __DIR__.'/vendor/mylib/libmylib');
Which throws an error:
Call to undefined method Composer\Autoload\ClassLoader::registerNamespace()
Which searching looks like ClassLoader included in Symfony2 is not the same as component ClassLoader, and you must install this component in order to include third party libraries using this method.
So, I try to follow the cryptic instructions to install this and looks like I need to install Composer (I'm under Windows), update my composer.json with these 2 lines (I made up the version number according to packagist):
"symfony/finder": "2.2.*",
"symfony/class-loader": "2.4.*",
And the execute composer install
in my command line (just under symfony folder), I did and nothing happened, I get this message:
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.
So I'm more lost than when I began; how do I include a 3rd party lib? How do I install components?
Thanks
Upvotes: 0
Views: 749
Reputation: 10085
Forget the class loader and registering manually the namespace, as the autoloader is generated by composer. But two options. Ask the developer to add a composer.json to the library and publish on packagist. Or include it yourself as a package repository in your composer.json described in the composer docs: http://getcomposer.org/doc/05-repositories.md#package-2
Edit: after changing something in the composer.json you need to run update and not install. As a hint ;-)
Upvotes: 1