Question

I decided to get my feet wet in the Phalcon internals by making a simple validator. I followed the definition of the other validators almost verbatim. So here is what I have in phalcon.c and phalcon.h:

phalcon.c:
zend_class_entry *phalcon_mvc_model_validator_stringlength_ce;
...
PHALCON_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\Validator, StringLength, mvc_model_validator_stringlength, "phalcon\\mvc\\model\\validator", phalcon_mvc_model_validator_stringlength_method_entry, 0);

phalcon.h:
extern zend_class_entry *phalcon_mvc_model_validator_stringlength_ce;
...
ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_model_validator_stringlength_validate, 0, 0, 1)
    ZEND_ARG_INFO(0, record)
ZEND_END_ARG_INFO()
...
PHALCON_INIT_FUNCS(phalcon_mvc_model_validator_stringlength_method_entry){
    PHP_ME(Phalcon_Mvc_Model_Validator_StringLength, validate, arginfo_phalcon_mvc_model_validator_stringlength_validate, ZEND_ACC_PUBLIC)
    PHP_FE_END
};

At runtime I get the following warning:

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626/phalcon.so' - /usr/lib/php5/20090626/phalcon.so: undefined symbol: zim_Phalcon_Mvc_Model_Validator_StringLength_validate in Unknown on line 0

What am I missing?

Was it helpful?

Solution

also it's needed to add the method (function) prototype to phalcon.h:

https://github.com/phalcon/cphalcon/blob/master/dev/phalcon.h#L391

Add your .c file to config.m4 (if you're on a Unix/Linux platform):

https://github.com/phalcon/cphalcon/blob/master/dev/config.m4#L5

After that, a full recompilation is required:

phpize --clean
export CFLAGS="-g -O2 -fno-delete-null-pointer-checks"
phpize
./configure --enable-phalcon
make
sudo make install
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top