Skip to content

Commit

Permalink
Add support for php 8.3 and librdkafka 2.1.0, 2.1.1, 2.2.0, 2.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dirx committed Dec 23, 2023
1 parent 18d49e2 commit d37c907
Show file tree
Hide file tree
Showing 21 changed files with 6,062 additions and 655 deletions.
2 changes: 2 additions & 0 deletions .ffigen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ headerFiles:
- rdkafka_mock.h
headerSearchPaths:
- resources/ffigen/tmp
- /usr/include/aarch64-linux-gnu
- /opt/homebrew/include
libraryFile: librdkafka.so.1
generatorClass: RdKafka\FFIGen\MultiVersionGenerator
outputPath: resources/ffigen/tmp
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:
fail-fast: true
matrix:
php:
- '8.0'
- '8.1'
- '8.2'
- '8.3'
defaults:
run:
shell: bash
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ jobs:
fail-fast: true
matrix:
php:
- '8.0'
- '8.1'
- '8.2'
- '8.3'
librdkafka:
- '2.0.2'
- '2.3.0'
defaults:
run:
shell: bash
Expand All @@ -35,9 +35,9 @@ jobs:
run: |
nuget install librdkafka.redist -Version ${{ matrix.librdkafka }}
choco install --no-progress wget nssm
wget -q -O kafka_2.13-3.3.2.tgz http://ftp.fau.de/apache/kafka/3.3.2/kafka_2.13-3.3.2.tgz
tar -xzf kafka_2.13-3.3.2.tgz
cp -pr kafka_2.13-3.3.2 /c/kafka
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
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
16 changes: 10 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,23 @@ jobs:
fail-fast: false
matrix:
include:
- php: '8.0'
librdkafka: 'v2.0.2'
- php: '8.1'
librdkafka: 'v2.3.0'
publish: true
exclude:
- php: '8.0'
librdkafka: 'v2.0.2'
- php: '8.1'
librdkafka: 'v2.3.0'
publish: false
php:
- '7.4'
- '8.0'
- '8.1'
- '8.2'
- '8.3'
librdkafka:
- 'v2.3.0'
- 'v2.2.0'
- 'v2.1.1'
- 'v2.0.2'
- 'v1.9.2'
- 'v1.8.2'
Expand All @@ -42,14 +46,14 @@ jobs:
continue-on-error: ${{ matrix.librdkafka == 'master' }}
services:
zookeeper:
image: confluentinc/cp-zookeeper:7.3.1
image: confluentinc/cp-zookeeper:7.5.2
ports:
- 2181:2181
env:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
kafka:
image: confluentinc/cp-kafka:7.3.1
image: confluentinc/cp-kafka:7.5.2
ports:
- 9092:9092
env:
Expand Down
15 changes: 13 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ networks:

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

kafka:
image: confluentinc/cp-kafka:7.3.1
image: confluentinc/cp-kafka:7.5.2
ports:
- 9092:9092
hostname: kafka
Expand Down Expand Up @@ -90,6 +90,17 @@ services:
networks:
- php-rdkafka-ffi

php83:
build:
context: resources/docker/php83-librdkafka-ffi
image: php83-librdkafka-ffi:latest
volumes:
- .:/app
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.0.2
ARG LIBRDKAFKA_VERSION=v2.3.0
ENV LIBRDKAFKA_VERSION=$LIBRDKAFKA_VERSION
RUN set -e; \
apt-get update; \
Expand Down
4 changes: 2 additions & 2 deletions resources/docker/php80-librdkafka-ffi/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM php:8.0-cli

# enable ffi and install librdkafka
ARG LIBRDKAFKA_VERSION=v2.0.2
ARG LIBRDKAFKA_VERSION=v2.3.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; \
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; \
Expand Down
6 changes: 4 additions & 2 deletions resources/docker/php81-librdkafka-ffi/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM php:8.1-cli

# enable ffi and install librdkafka
ARG LIBRDKAFKA_VERSION=v2.0.2
ARG LIBRDKAFKA_VERSION=v2.3.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; \
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; \
Expand Down Expand Up @@ -33,6 +33,8 @@ RUN git clone --branch "$RDKAFKA_EXT_VERSION" --depth 1 https://github.com/arnau
make install; \
rm -rf /tmp/*;

RUN apt-get install -y --no-install-recommends git zip unzip gdb libffi-dev libc6-dev;

ENV COMPOSER_HOME /tmp
ENV COMPOSER_ALLOW_SUPERUSER 1
COPY --from=composer /usr/bin/composer /usr/bin/composer
Expand Down
4 changes: 2 additions & 2 deletions resources/docker/php82-librdkafka-ffi/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM php:8.2-cli

# enable ffi and install librdkafka
ARG LIBRDKAFKA_VERSION=v2.0.2
ARG LIBRDKAFKA_VERSION=v2.3.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; \
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; \
Expand Down
47 changes: 47 additions & 0 deletions resources/docker/php83-librdkafka-ffi/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
FROM php:8.3-cli

# enable ffi and install librdkafka
ARG LIBRDKAFKA_VERSION=v2.3.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
2 changes: 1 addition & 1 deletion resources/ffigen/LibrdkafkaHeaderFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,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.1.0')) {
if (Comparator::greaterThanOrEqualTo($version, '1.0.0') && Comparator::lessThan($version, '2.4.0')) {
$supportedVersions[$version] = sprintf(
self::DOWNLOAD_BASE_URL_TEMPLATE,
$release->tag_name
Expand Down
4 changes: 2 additions & 2 deletions src/RdKafka/FFI/Library.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class Library
use Methods;

public const VERSION_AUTODETECT = '';
public const VERSION_LATEST = '2.0.2';
public const PHP_LIBRARY_VERSION = '0.5.0';
public const VERSION_LATEST = '2.3.0';
public const PHP_LIBRARY_VERSION = '0.6.0';

private static FFI $ffi;
private static string $scope = 'RdKafka';
Expand Down
Loading

0 comments on commit d37c907

Please sign in to comment.