Umar3x
Umar3x

Reputation: 1084

How to install vendor bundle WITHOUT composer (corporate network)

First of all, I can't use composer because Im under a corporate network. I tried everything to get composer working :

SSL : Handshake timed out.

But that's not my question, I spent to much time trying to get composer working (But if you got a solution, you'll make my day )

My real question is the following : How to install bundles manually

I want to install this bundle : http://knpbundles.com/pierredup/MenuBundle.

What I did to try installing the bundle :

new \CS\MenuBundle\CSMenuBundle()

$loader->add('CS', __ DIR __.'/../vendor/CS/CSMenuBundle.php');

(Dont know how to add php code properly ... )

But it doesn't work, got the following error :

Attempted to load class "CSMenuBundle" from namespace "CS\MenuBundle". Did you forget a "use" statement for another namespace?

And then, even if it is not a good practise, I tried to add it to autoload_namespaces.php and did a dump-autoload after that :

'CS\MenuBundle' => array($vendorDir. '/CS/')

I still have an error, but not exactly the same one :

Attempted to load class "CSMenuBundle" from namespace "CS\MenuBundle". Did you forget a "use" statement for "CS\MenuBundle\CSMenuBundle"?

Now I'm a bit frustrating, I saw many posts (not on Stack) where people scream because we have to use composer to manage dependencies. I totally agree with that, but I can't, so I'm trying to find another way, and as I can't find any clear tutorial which explains how to install vendors without composer, here I am.

Upvotes: 3

Views: 6924

Answers (1)

Sven
Sven

Reputation: 70853

Note that I commented on the problems I see with your approach on your question directly.

However, I looked at the package you want to use to see if there would be ANY chance installing it somehow (preferring Composer). I don't think it is possible or feasible.

composer require customscripts/menubundle:dev-master - this would be the easy command for Composer to do everything. However there are problems:

  1. The package you want to use is not registered on packagist.org, so there is no way to simply use Composer on a machine properly connected to the internet, grab the packages, zip them and transfer them to the place you need it.

  2. To work around this, you'd manually add the repository to the composer.json file - this might actually work (however it takes way too much time on my VM). You'll end up with code that was last edited in the year 2012!

  3. The dependencies of that code will likely not work anymore. The composer.json of that package lists "require": {"knplabs/knp-menu-bundle": "dev-master", "symfony/framework-bundle": ">=2.0,<2.3-dev", "jms/di-extra-bundle": "1.1.*"} - even the first "knplabs/knp-menu-bundle" will never work. Remember that the code of this package is from 2012 - now we are in 2016, so "knp-menu-bundle" has seen four years of development on the master branch. There simply is NO WAY of knowing which commit had been used of this package. You'd have to reverse-engineer this lost information.

  4. Additionally, you see why Composer is awesome and doing it manually is bad: In addition to your wished package, you have to download the three additional packages mentioned here.

  5. But detecting packages that have to be added is a recursive task: knp-menu-bundle has a dependency on knp-menu (with no further dependencies) and symfony/framework-bundle (already added). symfony/framework-bundle itself has a dependency on 9 more Symfony packages and doctrine/common... and so on. You have to detect every single package of this and download the correct version manually if you cannot use Composer.

Skipping your original package because that installation wasn't finishing while I was typing my answer, I tried to install knp-menu-bundle to see how many packages would be installed. Composer installed 20 packages, some of them using Symfony in 2.8 (it SHOULD be compatible with Symfony 2.2 stuff, shouldn't it) - and I simply ran composer require knplabs/knp-menu-bundle:1.1.1 to grab a similarly old version of knp-menu-bundle from 2012.

The strength of using Composer is that it supports rapid development by allowing updating quickly, downgrading reliably (if you commit your composer.lock file and always use tagged versions), and simply allowing to add new packages instantly. Not being able to use Composer is a very severe limitation for you as a PHP developer. Talk to your boss or team lead about your company's situation with the HTTPS proxy, and find a solution to use Composer. The alternative is to develop everything from scratch on your own or waste plenty of hours trying to fiddle with manual downloads that don't fit together easily.

Upvotes: 1

Related Questions