vercel-community / php

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

Kirby support: possible conflict with Kirby go() function and swoole extension go() function. #133

Open dadambickford opened 4 years ago

dadambickford commented 4 years ago

Bug report

Description

The PHP error is

Fatal error: Cannot redeclare go() in /var/task/user/kirby/config/helpers.php on line 222

We can not figure out the source of the original go() function that kirby is conflicting with. We've discovered many different forms of using PHP reflection to try and find the source with no luck - https://stackoverflow.com/questions/7026690/reconstruct-get-code-of-php-function - and posting our own question - https://stackoverflow.com/questions/64867808/get-function-definition-in-string-form-in-php

The only hint that we found is that the PHP extension swoole has a go() function that sounds like it may be the conflict (https://github.com/getkirby-v2/kirby/issues/643) however all of our attempts to disable that extension have failed, like overriding the php.ini config. Is there a way to not include that with vercel-php? maybe a past version that doesn't have it? or any other ideas?

Thanks in advance.

f3l1x commented 4 years ago

Hi @dadambickford. Thank you for issue. That's really strange error, but I got it you need to disable some php extension. I think there is now way how to disable already enabled extension, right? I need to think about it and introduce some logic to build phase, how to comment-out particular extension.

Something like:

{
  "build": {
    "env" : {
      "VERCEL_PHP_DISABLE_EXTENSIONS": "swoole", 
      # maybe in conjunction
      "VERCEL_PHP_ENABLE_EXTENSIONS": "json curl ..."
    }
  }
}
dadambickford commented 4 years ago

I'm admittedly very amateur when it comes to PHP, so I can't say for sure. We did read about a PHP_MODULES_DISABLE environment variable but passing that with the swoole value did not do what we hoped. The php.ini override we attempted was just setting extensions to an empty string, but yeah that didn't disable it.

I think a config option would be a clean solution, and if we eventually get this sorted out I'd love to submit a working Kirby boilerplate to the examples repo.

dadambickford commented 3 years ago

Hi there @f3l1x, wanted to touch base on this again and see if you've had any time to think about it.

f3l1x commented 3 years ago

Hi @dadambickford. Unfortunately no, I tried to enjoy Christmas time. :-) I've released new v0.4.0 with PHP 8.0. Could you please test it? If so, this will be my next issue.

dadambickford commented 3 years ago

No worries! Hope you had a good holiday. I will give that a test and let you know.

leocavalcante commented 2 years ago

Add swoole.use_shortname=Off to your php.ini file. It will make Swoole skip the go() function creation.

f3l1x commented 2 years ago

@leocavalcante It works for me. Can you confirm it @dadambickford ?