vercel-community / php

🐘 PHP Runtime for ▲ Vercel Serverless Functions (support 7.4-8.3)

Home Page:https://php.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

dadambickford opened this issue · comments

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.

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 ..."
    }
  }
}

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.

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

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.

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

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

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