diff --git a/README.md b/README.md index fe0fed4..acfae8f 100644 --- a/README.md +++ b/README.md @@ -11,20 +11,29 @@ php-stem requires three files: The stem.so file depends on arch and php version. -* Apt install php-dev -* cd to src -* phpize -* ./configure -* make -* make test +* `apt install php-dev` +* `cd to src` +* `phpize` +* `./configure` +* `make` +* `make test` (might fail ...?) -See the README in the src directory -### Deployment +### Installing/Enabling the Module +Note: These steps tested on Ubuntu 22.04 with PHP 8.1 and php-fpm. Paths on other distros may vary. + +* ... while still in `src` directory: +* Install module + * `sudo make install` + * This will copy the .so file into `/usr/lib/php/yyyymmdd/' where yyyymmdd is the date computed by phpize +* Create .ini + * `sudo cp stem.ini /etc/php/8.1/mods-available/` +* Enable module for php-fpm + * `sudo phpenmod stem` +* Reload php-fpm + * `sudo service php8.1-fpm reload` -The stem.ini file goes in /etc/php/N.M/mods-available/ where N and M are the major and minor versions of php -The stem.so file goes in /usr/lib/php/yyyymmdd/ where yyyymmdd is the date computed by phpize ### Source diff --git a/so/stem-x64-8.1.so b/so/stem-x64-8.1.so new file mode 100755 index 0000000..a0fac28 Binary files /dev/null and b/so/stem-x64-8.1.so differ diff --git a/src/stem.c b/src/stem.c index 7d4d08d..11ad5f5 100644 --- a/src/stem.c +++ b/src/stem.c @@ -29,7 +29,7 @@ #include "php_ini.h" #include "ext/standard/info.h" #include "php_stem.h" -#if PHP_MAJOR_VERSION == 7 +#if PHP_MAJOR_VERSION >= 7 ZEND_BEGIN_ARG_INFO_EX(arginfo_stem_params, 0, 0, 1) ZEND_ARG_INFO(0, string) ZEND_ARG_INFO(0, lang) @@ -158,7 +158,7 @@ void php_stem(INTERNAL_FUNCTION_PARAMETERS, long lang) void (*close_env)(struct SN_env*); int (*stem)(struct SN_env*); -#if PHP_MAJOR_VERSION == 7 +#if PHP_MAJOR_VERSION >= 7 const char* incoming; size_t arglen; #else @@ -172,7 +172,7 @@ void php_stem(INTERNAL_FUNCTION_PARAMETERS, long lang) /* Empty string */ if (arglen <= 0) { -#if PHP_MAJOR_VERSION == 7 +#if PHP_MAJOR_VERSION >= 7 RETURN_STRINGL(incoming, arglen); #else RETURN_STRINGL(incoming, arglen, 1); @@ -191,7 +191,7 @@ void php_stem(INTERNAL_FUNCTION_PARAMETERS, long lang) #undef STEMMER default: - php_error(E_NOTICE, "%s() couldn't stem word, stemming module not found", get_active_function_name(TSRMLS_C)); + php_error(E_NOTICE, "%s() couldn't stem word, stemming module not found", get_active_function_name()); RETURN_FALSE; } @@ -201,7 +201,7 @@ void php_stem(INTERNAL_FUNCTION_PARAMETERS, long lang) stem(z); z->p[z->l]= '\0'; -#if PHP_MAJOR_VERSION == 7 +#if PHP_MAJOR_VERSION >= 7 RETVAL_STRINGL(z->p,z->l); #else RETVAL_STRINGL(z->p,z->l, 1); @@ -245,7 +245,7 @@ PHP_FUNCTION(stem_enabled) { int lang; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &lang) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() , "l", &lang) == FAILURE) { RETURN_FALSE; } diff --git a/src/stem.ini b/src/stem.ini new file mode 100644 index 0000000..473236d --- /dev/null +++ b/src/stem.ini @@ -0,0 +1 @@ +extension=stem.so