Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

php-stem for PHP 8.1 #4

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Binary file added so/stem-x64-8.1.so
Binary file not shown.
12 changes: 6 additions & 6 deletions src/stem.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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);
Expand All @@ -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;
}

Expand All @@ -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);
Expand Down Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions src/stem.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extension=stem.so