在共享主机上安装单个编写器包的建议

We have a web application running on a shared hosting account that was built using Laravel. We now need to implement a payment gateway that requires vendor packages for the SDKs. However as mentioned composer is not supporting at all with the current hosting company.

Steps we took to get Laravel up and running on shared host:

  • We developed the application locally first on a development machine
  • Added version control and pushed the files to GitHub
  • We used SSH to gain access and then did a git pull to the server

We unfortunately had to package the vendor folder separately and push that over to the server (as this is not highly recommended without composer) it was our only option at the time.

By some miracle we got the application to run without any issues.

The problem we face now, is that we need to install SDK packages through composer for the payment gateway we need to implement.

We did the initial setup and build of the new module on the development machine first, but the problem we now face is, simply pushing the SDK into the vendor folder does not work, it still moans about the class files not being found. and there is no way for me to do a composer dump-autoload -o

We even went as far as re-packaging the updated version of the vendor folder, deleting the current one on the application and then doing another pull down from GitHub, but that throws all sorts of bootstrap/app.php issues with classes not being found.

We did try force allow_url_fopen=1 with a manually downloaded version of composer, but the shared hosting PHP CLI is 5.6 and PHP 7.0 is required.

We are unfortunately stuck and any advice would be highly appreciated.

Try copying over composer.json and composer.lock and run the php artisan commands found in the composer.json

Some background:

PHP5.6 is outdated and not supported anymore by PHP. Therefore a lot of hosters remove this version from theirs servers (at least in Germany). Some already started and others will do beginning of 2019. For my experience hosters have already newer versions available on their servers, which need to be activated manually in the configuration panel by domain.

For the CLI PHP you can check this by ssh to your server and type php followed by hitting TAB two times. This gave me this:

php php53 php54 php55 php56 php70 php71 php72

Composer uses the default /usr/bin/php, which might be symlinked to php56 on your webspace. However, you can call Composer also with any other PHP version by:

php71 composer.phar

If your hoster does not support any newer PHP version I would demand it from him for security reasons or migrate to another one ASAP.