After spending a few hours debugging through native code that worked on PHP 5.6 (and PHP-CPP legacy), it looks like the recent 2.0.0 release is not playing nice when objects are passed in.
I've managed to whittle down the problem to what essentially looks like an issue with accessing PHP objects.
Example:
#include <phpcpp.h>
#include <iostream>
void test(Php::Parameters ¶ms)
{
Php::Value obj = params[0];
std::cout << obj["test"] << std::endl;
}
extern "C" {
PHPCPP_EXPORT void *get_module() {
static Php::Extension extension("php_cpp", "1.0");
extension.add<test>("test", {
Php::ByRef("obj",` Php::Type::Null, false);
});
return extension;
}
}
And then a test script to confirm:
$foo = new stdClass;
$foo->test = 23;
test($foo);
Results in a segfault. Passing $foo = ['test' => 23] (as an array) to the function has no issues.
Tested on PHP-CLI 7.0.12. The header file being used reported by php-config also matches this version, so I do not believe there were any compilation issues when building 2.0.
After spending a few hours debugging through native code that worked on PHP 5.6 (and PHP-CPP legacy), it looks like the recent 2.0.0 release is not playing nice when objects are passed in.
I've managed to whittle down the problem to what essentially looks like an issue with accessing PHP objects.
Example:
And then a test script to confirm:
Results in a segfault. Passing
$foo = ['test' => 23](as an array) to the function has no issues.Tested on PHP-CLI 7.0.12. The header file being used reported by php-config also matches this version, so I do not believe there were any compilation issues when building 2.0.