vercel-community / php

🐘 PHP Runtime for ▲ Vercel Serverless Functions (support 7.4-8.3)
https://php.vercel.app
MIT License
1.24k stars 285 forks source link

Custom PHP runtime #143

Open WilliamBlais opened 3 years ago

WilliamBlais commented 3 years ago

Question

Hi, I would like to build a custom PHP library using https://github.com/juicyfx/libphp/tree/master/libs/amazon-linux-2-v80. However, Vercel-php assumes we're using @libphp/amazon-linux-2-v80. Would it be possible to make that a setting? Would it be possible to remove @libphp/amazon-linux-2-v80 from package.json and download it at build time instead?

Maybe I could create a script that lets you choose which PHP extension you want, build it and publish it to NPM. Then the user would be able to use his own custom library.

Thanks!

f3l1x commented 3 years ago

Hi, thanks for question. I think I can install PHP during build time. But it requires little research. I hope it wouldn't be slower.

WilliamBlais commented 3 years ago

@f3l1x thanks for the quick answer! Do you think it would be a good solution to modify getPhpFiles() in utils.ts to to download the file directly from npm and unzip it? Sounds possible?

Something like this; curl https://registry.npmjs.org/PACKAGE-NAME/ \ | jq '.versions[."dist-tags".latest].dist.tarball'

f3l1x commented 3 years ago

I was using on-the-fly installation in early versions of vercel-php. It was harder to maintain it. What is your motivation to install custom PHP library?