This is how I loaded a legacy budle without composer.json in a custom location for my Symfony2.3project with composer.
In one of my Symfony2.3 projects I needed to use an old external bundle. This legacy bundle (from Symfony2.0) hasn’t a composer.json file and in my case I can not add one.
Anyway, I wanted to use composer and its autoloader also for this bundle in order to keep things simple for me.
Let’s assume I wanted to add TwitterClientBundle and its namespace is: Razvan\TwitterClientBundle
For this I added in my composer.json the following:
{ "name": "symfony/framework-standard-edition", "license": "MIT", "type": "project", "description": "The \"Symfony Standard Edition\" distribution", "autoload": { "psr-0": { "": "src/", "Razvan\\TwitterClientBundle": "vendor/razvan/twitter-client-bundle" } }, "repositories": [ { "type": "package", "package": { "name": "razvan/twitter-client-bundle/Razvan/TwittereClientBundle", "version": "4.4.3", "source": { "url": "https://github.com/raztud/TwittereClientBundle", "type": "git", "reference": "master" } } } ], "require": { "razvan/twitter-client-bundle/Razvan/TwitterClientBundle": "*" }, ...
After that I ran:
php composer.phar update razvan/twitter-client-bundle
and the bundle was added in /path/to/yourproject/vendor/razvan/twitter-client-bundle/
eg:
razvan@main2:/var/www/twitter/vendor/razvan/twitter-client-bundle$ tree . --- Razvan --- TwitterClientBundle --- DependencyInjection --- RazvanTwitterClientExtension.php --- RazvanTwitterClientBundle.php --- Manager ....
After that I enabled the bundle in AppKernel.php
new Razvan\TwitterClientBundle\RazvanTwitterClientBundle()
and this was all.
Disclaimer:
- Maybe there are better solution, but I did not find them yet.
- The bundle RazvanTwitterBundle doesn’t exist on Github.
P.S. Somebody else wrote a similar post in the past.