How do I install Composer PHP packages without Composer?

前端 未结 7 844
有刺的猬
有刺的猬 2020-12-04 06:04

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 (per

7条回答
  •  执念已碎
    2020-12-04 06:30

    I'm using shared hosting for a website and can't execute commands there. Aside from running composer via php script request that I request via browser, I usually use this workflow:

    • Make sure you have php installed locally.
    • Make directory on desktop.
    • download composer.phar from https://getcomposer.org/download/ (under header *Manual Download) and place it in the directory.
    • make a file composer.json paste in it the following contents

       {
           "require": {
               "coinbase/coinbase": "~2.0"
           }
       }
      
    • Browse to the directory with the shell of your choice(bash, git-bash, cmd, windows bash)

    • type php composer.phar update
    • Upload the vendor directory to your webserver via ftp or whatever mechanic you use.
    • include in your php project where you load your libraries(modify path to where you uploaded the vendor dir so it will include that autoload file)

      require_once('vendor/autoload.php');
      

    This way you get the benefit of dependency management and you don't have to include manually all the gazillion of files and download all the dependencies manually, and updating them is just as easy as typing php composer.phar update and then replacing the vendor dir on your server with the new one.

提交回复
热议问题