vercel-community/php

How to setup composer with vercel-php

TechPhil opened this issue · 1 comments

Question

I'm trying to deploy a very basic PHP project to Vercel using vercel-php.
The project relies on some composer dependencies - grpc/grpc and google/cloud-firestore
How exactly do I setup my project for these composer dependencies to be installed correctly and working.
I have tried following the example here - https://github.com/juicyfx/vercel-examples/tree/master/php-composer, although it's slightly unclear as to how exactly to achieve this.

Any advice greatly appreciated.

Hi All,

Some tinkering later and I seem to have cracked it -

the best way I have found is to have your composer.json in the root of your project, and in the file in your api folder (e.g. /api/index.js) do a require from $_SERVER["DOCUMENT_ROOT"] . "/vendor/autoload.php"