How do I install Composer PHP packages without Composer?

I'm trying to install the Coinbase PHP API but it requires Composer:

https://github.com/coinbase/coinbase-php

I'm looking for a universal PHP solution (perhaps a function) to let me install composer packages directly onto my server, without having to use Composer.

I think the developers of Composer believe they are helping people, but actually there are thousands of beginner developers that are being locked out of learning web development by the 'Composer barrier'.

It would really help if there was a flexible solution or some approach where we could install without Composer? How can I do this?

Please don't respond with some sarcastic comment. There are people that don't want to use Composer and I don't see why we should be herded into a specific third-party software in order to do web development.


Solution 1:

You can try https://php-download.com/ which can help you download all dependency most of the time along with vendor folder. It promises composer not required. Tried it myself. It finds and creates all required folders and zips it for download. Works perfectly !!

Solution 2:

The composer.json file lists the dependencies. In your example:

"require": {
    "php": ">=5.5.0",
    "guzzlehttp/guzzle": "^6.0",
    "psr/http-message": "^1.0",
    "psr/log": "^1.0"
},

You must then find the corresponding packages in the packagist site. Repeat the same process for each dependency: find additional dependencies in their corresponding composer.json files and search again.

When you finally have a complete list of the required packages, you only need to install them all one by one. For the most part, it's just a matter of dropping the files somewhere in your project directory. But you must also ensure that PHP can find the needed classes. Since you aren't using Composer's auto-loader, you need to add them to your own custom autoloader. You can figure out the information from the respective composer.json files, e.g.:

"autoload": {
    "psr-4": { "Coinbase\\Wallet\\": "src/" }
},

If you don't use a class auto-loader you'll need to figure out the individual require_once statements. You'll probably need a lot of trial and error because most library authors won't care documenting that.

Also, and just in case there's confusion about this:

  • Composer has an official GUI installer for Windows and a copy and paste command-line installation procedure for all platforms.
  • Composer can be run locally and its output just uploaded elsewhere. You don't need SSH in your shared hosting.
  • The command needed to install a library can be copied and pasted from the package web site—even if the package maintainer didn't care to document it, packagist.org generates it by default.

Composer is not perfect and it doesn't suit all use cases but, when it comes to installing a library that relies on it, it's undoubtedly the best alternative and it's a fairly decent one.


I've checked other answers that came after mine. They mostly fall in two categories:

  1. Install a library and write a custom download script with it
  2. Use an online web based interface for Composer

Unless I'm missing something, none of them address the complaints expressed by the OP:

  • Learning curve
  • Use of third-party software
  • Possibility to develop right on the server (using SSH, I presume)
  • Potentially deep dependency tree