How to install Composer PHP package without Composer?
P粉278379495
2023-08-22 12:37:12
<p>I'm trying to install the Coinbase PHP API but it requires Composer: </p>
<p>https://github.com/coinbase/coinbase-php</p>
<p>I'm looking for a general PHP solution (perhaps a function) that would allow me to install Composer packages directly on the server without having to use Composer. </p>
<p>I think the developers of Composer think they are helping people, but there are actually thousands of beginner developers who are unable to learn web development because of "Composer Barrier". </p>
<p>If there is a flexible solution or some way to install without Composer? what should I do? </p>
<p><strong>Please do not reply to sarcastic comments</strong>. Some people don't want to use Composer, and I don't see why we should be forced to use specific third-party software for web development. </p>
You can try https://php-download.com/, it can help you download all dependencies most of the time, along with
vendor
folder. It promises that composer is not required. I tried it myself. It will find and create all required folders and zip them for download. Works perfectly! !In your example, the
composer.json
file lists the dependencies.Then, you need to find the corresponding package on the packagist website. For each dependency, repeat the same process: find the other dependencies in their corresponding
composer.json
files and search again.When you finally have the complete list of required packages, you just need to install them one by one. In most cases, simply placing the file somewhere in the project directory will suffice. But you also have to make sure PHP can find the required classes. Since you're not using Composer's autoloader, you'll need to add them to your own custom autoloader. You can get the information from the corresponding
composer.json
file, for example:If you are not using a class autoloader, you need to find the individual
require_once
statements. Since most library authors won't care about this, you may need to do a lot of trial and error.Also, in case there is any confusion on this matter:
Composer is not perfect, nor is it suitable for all use cases, but when it comes to installing libraries that depend on it, it is undoubtedly the best choice, and a pretty good one at that.
I looked at the other answers after my answer. They are mainly divided into two categories:
Unless I'm missing something, none of them address the question raised by the OP: