Skip to content

Commit

Permalink
Add support for PHP 8.4 and librdkafka 2.4.0, 2.5.0, 2.5.3, 2.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dirx committed Oct 21, 2024
1 parent c89ff42 commit d4525e5
Show file tree
Hide file tree
Showing 51 changed files with 5,799 additions and 697 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test-extension-compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ jobs:
php:
- '8.1'
librdkafka:
- 'v1.9.2'
- 'v2.6.0'
rdkafka:
- '6.x'
services:
zookeeper:
image: confluentinc/cp-zookeeper:7.5.3
image: confluentinc/cp-zookeeper:7.7.1
ports:
- 2181:2181
env:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
kafka:
image: confluentinc/cp-kafka:7.5.3
image: confluentinc/cp-kafka:7.7.1
ports:
- 9092:9092
env:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/test-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
- '8.1'
- '8.2'
- '8.3'
- '8.4'
defaults:
run:
shell: bash
Expand Down Expand Up @@ -46,7 +47,7 @@ jobs:
php-version: ${{ matrix.php }}
coverage: none
extensions: ffi, pcntl
ini-values: "${{ matrix.php == '8.3' && 'zend.max_allowed_stack_size=256k' || '' }}"
ini-values: "${{ (matrix.php == '8.3' || matrix.php == '8.4') && 'zend.max_allowed_stack_size=256k' || '' }}"

- name: Install dependencies
uses: ramsey/composer-install@v2
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ jobs:
- '8.1'
- '8.2'
- '8.3'
- '8.4'
librdkafka:
- '2.3.0'
- '2.6.0'
defaults:
run:
shell: bash
Expand All @@ -35,9 +36,9 @@ jobs:
run: |
nuget install librdkafka.redist -Version ${{ matrix.librdkafka }}
choco install --no-progress wget nssm
wget -q -O kafka_2.13-3.6.1.tgz http://ftp.fau.de/apache/kafka/3.6.1/kafka_2.13-3.6.1.tgz
tar -xzf kafka_2.13-3.6.1.tgz
cp -pr kafka_2.13-3.6.1 /c/kafka
wget -q -O kafka_2.13-3.8.0.tgz http://ftp.fau.de/apache/kafka/3.8.0/kafka_2.13-3.8.0.tgz
tar -xzf kafka_2.13-3.8.0.tgz
cp -pr kafka_2.13-3.8.0 /c/kafka
sed -i "s|broker.id=0|broker.id=111|g" /c/kafka/config/server.properties
nssm install zookeeper /c/kafka/bin/windows/zookeeper-server-start.bat /c/kafka/config/zookeeper.properties
nssm set zookeeper AppExit Default Exit
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,23 @@ jobs:
matrix:
include:
- php: '8.1'
librdkafka: 'v2.3.0'
librdkafka: 'v2.6.0'
publish: true
exclude:
- php: '8.1'
librdkafka: 'v2.3.0'
librdkafka: 'v2.6.0'
publish: false
php:
- '7.4'
- '8.0'
- '8.1'
- '8.2'
- '8.3'
- '8.4'
librdkafka:
- 'v2.6.0'
- 'v2.5.3'
- 'v2.4.0'
- 'v2.3.0'
- 'v2.2.0'
- 'v2.1.1'
Expand All @@ -46,14 +50,14 @@ jobs:
continue-on-error: ${{ matrix.librdkafka == 'master' }}
services:
zookeeper:
image: confluentinc/cp-zookeeper:7.5.3
image: confluentinc/cp-zookeeper:7.7.1
ports:
- 2181:2181
env:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
kafka:
image: confluentinc/cp-kafka:7.5.3
image: confluentinc/cp-kafka:7.7.1
ports:
- 9092:9092
env:
Expand Down
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

## [0.6.0]

This pre-release improves compatible with the [PHP RdKafka extension](https://github.com/arnaud-lb/php-rdkafka) ^5.0 and ^6.0.

### Added

- Add support for PHP 8.3 and librdkafka 2.1.0, 2.1.1, 2.2.0, 2.3.0
- Add support for PHP 8.3 and 8.4
- Add support for librdkafka 2.1.0, 2.1.1, 2.2.0, 2.3.0, 2.4.0, 2.5.0, 2.5.3, 2.6.0

### Fixed

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"ext-rdkafka": "*"
},
"require-dev": {
"phpunit/phpunit": "^9.4",
"phpunit/phpunit": "^9.4 || ^10.5",
"ircmaxell/php-c-parser": "dev-master#fd8f5efefd0fcc6c5119d945694acaa3a6790ada",
"symplify/easy-coding-standard": "^12.0",
"klitsche/ffigen": "0.8.1",
Expand Down
18 changes: 14 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
version: '3'

networks:
php-rdkafka-ffi:

services:
zookeeper:
image: confluentinc/cp-zookeeper:7.5.3
image: confluentinc/cp-zookeeper:7.7.1
ports:
- 2181:2181
environment:
Expand All @@ -15,7 +13,7 @@ services:
- php-rdkafka-ffi

kafka:
image: confluentinc/cp-kafka:7.5.3
image: confluentinc/cp-kafka:7.7.1
ports:
- 9092:9092
hostname: kafka
Expand Down Expand Up @@ -102,6 +100,18 @@ services:
networks:
- php-rdkafka-ffi

php84:
build:
context: resources/docker/php84-librdkafka-ffi
image: php84-librdkafka-ffi:latest
volumes:
- .:/app
- ./resources/docker/php84-librdkafka-ffi/php.ini:/usr/local/etc/php/php.ini
depends_on:
- kafka
networks:
- php-rdkafka-ffi

mkdocs:
build:
context: resources/docker/mkdocs-material
Expand Down
2 changes: 1 addition & 1 deletion resources/docker/php74-librdkafka-ffi/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM php:7.4-cli

# enable ffi and install librdkafka
ARG LIBRDKAFKA_VERSION=v2.3.0
ARG LIBRDKAFKA_VERSION=v2.6.0
ENV LIBRDKAFKA_VERSION=$LIBRDKAFKA_VERSION
RUN set -e; \
apt-get update; \
Expand Down
2 changes: 1 addition & 1 deletion resources/docker/php80-librdkafka-ffi/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM php:8.0-cli

# enable ffi and install librdkafka
ARG LIBRDKAFKA_VERSION=v2.3.0
ARG LIBRDKAFKA_VERSION=v2.6.0
ENV LIBRDKAFKA_VERSION=$LIBRDKAFKA_VERSION
RUN set -e; \
apt-get update; \
Expand Down
2 changes: 1 addition & 1 deletion resources/docker/php81-librdkafka-ffi/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM php:8.1-cli

# enable ffi and install librdkafka
ARG LIBRDKAFKA_VERSION=v2.3.0
ARG LIBRDKAFKA_VERSION=v2.6.0
ENV LIBRDKAFKA_VERSION=$LIBRDKAFKA_VERSION
RUN set -e; \
apt-get update; \
Expand Down
2 changes: 1 addition & 1 deletion resources/docker/php82-librdkafka-ffi/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM php:8.2-cli

# enable ffi and install librdkafka
ARG LIBRDKAFKA_VERSION=v2.3.0
ARG LIBRDKAFKA_VERSION=v2.6.0
ENV LIBRDKAFKA_VERSION=$LIBRDKAFKA_VERSION
RUN set -e; \
apt-get update; \
Expand Down
2 changes: 1 addition & 1 deletion resources/docker/php83-librdkafka-ffi/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM php:8.3-cli

# enable ffi and install librdkafka
ARG LIBRDKAFKA_VERSION=v2.3.0
ARG LIBRDKAFKA_VERSION=v2.6.0
ENV LIBRDKAFKA_VERSION=$LIBRDKAFKA_VERSION
RUN set -e; \
apt-get update; \
Expand Down
47 changes: 47 additions & 0 deletions resources/docker/php84-librdkafka-ffi/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
FROM php:8.4-rc-cli

# enable ffi and install librdkafka
ARG LIBRDKAFKA_VERSION=v2.6.0
ENV LIBRDKAFKA_VERSION=$LIBRDKAFKA_VERSION
RUN set -e; \
apt-get update; \
apt-get install -y --no-install-recommends git zip unzip gdb libffi-dev libc6-dev; \
docker-php-ext-configure ffi; \
docker-php-ext-install -j$(nproc) ffi pcntl; \
git clone --branch "${LIBRDKAFKA_VERSION}" --depth 1 https://github.com/confluentinc/librdkafka.git /tmp/librdkafka; \
cd /tmp/librdkafka; \
./configure; \
make; \
make install; \
ldconfig; \
apt-get autoremove -y; \
rm -rf /var/lib/apt/lists/*; \
rm -rf /tmp/*;

# install xdebug
ARG XDEBUG_VERSION=beta
RUN pecl install xdebug-${XDEBUG_VERSION}; \
docker-php-ext-enable xdebug;

# install rdkafka ext - this is just required to run the compatibility tests
ARG RDKAFKA_EXT_VERSION=6.x
RUN git clone --branch "$RDKAFKA_EXT_VERSION" --depth 1 https://github.com/arnaud-lb/php-rdkafka.git /tmp/php-rdkafka; \
cd /tmp/php-rdkafka; \
phpize; \
./configure; \
make; \
make install; \
rm -rf /tmp/*;

ENV COMPOSER_HOME /tmp
ENV COMPOSER_ALLOW_SUPERUSER 1
COPY --from=composer /usr/bin/composer /usr/bin/composer

RUN useradd -Ms /bin/bash --user-group --uid 2000 phpdev; \
mkdir /app; \
chown phpdev -R /app; \
chown phpdev -R /tmp;

USER phpdev

WORKDIR /app
1 change: 1 addition & 0 deletions resources/docker/php84-librdkafka-ffi/php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
zend.max_allowed_stack_size=256k
4 changes: 2 additions & 2 deletions resources/ffigen/LibrdkafkaHeaderFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class LibrdkafkaHeaderFiles
{
private const RELEASE_URL = 'https://api.github.com/repos/confluentinc/librdkafka/releases';
private const RELEASE_URL = 'https://api.github.com/repos/confluentinc/librdkafka/releases?per_page=100';
private const DOWNLOAD_BASE_URL_TEMPLATE = 'https://raw.githubusercontent.com/confluentinc/librdkafka/%s/src';

private ConfigInterface $config;
Expand Down Expand Up @@ -94,7 +94,7 @@ private function loadSupportedVersions(): array
foreach ($releases as $release) {
if ($release->prerelease === false) {
$version = str_replace('v', '', $release->tag_name);
if (Comparator::greaterThanOrEqualTo($version, '1.0.0') && Comparator::lessThan($version, '2.4.0')) {
if (Comparator::greaterThanOrEqualTo($version, '1.0.0') && Comparator::lessThan($version, '2.7.0')) {
$supportedVersions[$version] = sprintf(
self::DOWNLOAD_BASE_URL_TEMPLATE,
$release->tag_name
Expand Down
2 changes: 1 addition & 1 deletion src/RdKafka/FFI/Library.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Library
use Methods;

public const VERSION_AUTODETECT = '';
public const VERSION_LATEST = '2.3.0';
public const VERSION_LATEST = '2.6.0';
public const PHP_LIBRARY_VERSION = '0.6.0';

private static FFI $ffi;
Expand Down
Loading

0 comments on commit d4525e5

Please sign in to comment.