Skip to content

Commit

Permalink
Add php 8.4 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
julien-maurel committed Dec 30, 2024
1 parent 159b758 commit ae53f5d
Show file tree
Hide file tree
Showing 15 changed files with 150 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .ci/packer_cache.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ php:8.0-fpm
php:8.1-fpm
php:8.2-fpm
php:8.3-fpm
php:8.4-fpm
ruby:2.7.1-alpine3.12
ubuntu:20.04
"
Expand All @@ -26,7 +27,7 @@ if [ -x "$(command -v docker)" ]; then

# Make sure list of PHP versions supported by the Elastic APM PHP Agent is in sync.
# See the comment in .ci/shared.sh
for version in 7.2 7.3 7.4 8.0 8.1 8.2 8.3
for version in 7.2 7.3 7.4 8.0 8.1 8.2 8.3 8.4
do
PHP_VERSION=${version} make -f .ci/Makefile prepare || true
DOCKERFILE=Dockerfile.alpine PHP_VERSION=${version} make -f .ci/Makefile prepare || true
Expand Down
2 changes: 1 addition & 1 deletion .ci/shared.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ set -e
# *) docker-compose.yml in packaging/test

#
export ELASTIC_APM_PHP_TESTS_SUPPORTED_PHP_VERSIONS=(7.2 7.3 7.4 8.0 8.1 8.2 8.3)
export ELASTIC_APM_PHP_TESTS_SUPPORTED_PHP_VERSIONS=(7.2 7.3 7.4 8.0 8.1 8.2 8.3 8.4)

export ELASTIC_APM_PHP_TESTS_SUPPORTED_LINUX_NATIVE_PACKAGE_TYPES=(apk deb rpm)
export ELASTIC_APM_PHP_TESTS_SUPPORTED_LINUX_PACKAGE_TYPES=("${ELASTIC_APM_PHP_TESTS_SUPPORTED_LINUX_NATIVE_PACKAGE_TYPES[@]}" tar)
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/loop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
- "8.1"
- "8.2"
- "8.3"
- "8.4"
dockerfile:
- "Dockerfile"
- "Dockerfile.alpine"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/phpt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
- "8.1"
- "8.2"
- "8.3"
- "8.4"
steps:
# - uses: actions/checkout@v4
# - name: Fetch and extract latest release of apm-agent-php
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ jobs:
- "8.1"
- "8.2"
- "8.3"
- "8.4"
data: ${{ fromJson(needs.setup-build-matrix.outputs.matrix-combinations).include }}
env:
PHP_VERSION: ${{ matrix.php-version }}
Expand Down Expand Up @@ -94,6 +95,7 @@ jobs:
- "8.1"
- "8.2"
- "8.3"
- "8.4"
dockerfile:
- "Dockerfile"
- "Dockerfile.alpine"
Expand Down
3 changes: 2 additions & 1 deletion agent/native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ include(elastic_conan_debugsymbols)

# Install project dependencies

set(_supported_php_versions 72 73 74 80 81 82 83)
set(_supported_php_versions 72 73 74 80 81 82 83 84)

function(get_php_api_from_release php_version ret_val)
block(SCOPE_FOR VARIABLES)
Expand All @@ -54,6 +54,7 @@ function(get_php_api_from_release php_version ret_val)
set(_php_release_81 20210902)
set(_php_release_82 20220829)
set(_php_release_83 20230831)
set(_php_release_84 20240924)

set(${ret_val} ${_php_release_${php_version}})
return(PROPAGATE ${ret_val})
Expand Down
37 changes: 37 additions & 0 deletions agent/native/building/dependencies/php84/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: "php-headers-84"
version: "1.0"
php_source_version: 8.4.1

sources:
7.2.34:
linux:
- url: "https://www.php.net/distributions/php-7.2.34.tar.gz"
contentsRoot: "php-7.2.34"
7.3.33:
linux:
- url: "https://www.php.net/distributions/php-7.3.33.tar.gz"
contentsRoot: "php-7.3.33"
7.4.33:
linux:
- url: "https://www.php.net/distributions/php-7.4.33.tar.gz"
contentsRoot: "php-7.4.33"
8.0.28:
linux:
- url: "https://www.php.net/distributions/php-8.0.28.tar.gz"
contentsRoot: "php-8.0.28"
8.1.18:
linux:
- url: "https://www.php.net/distributions/php-8.1.18.tar.gz"
contentsRoot: "php-8.1.18"
8.2.5:
linux:
- url: "https://www.php.net/distributions/php-8.2.5.tar.gz"
contentsRoot: "php-8.2.5"
8.3.2:
linux:
- url: "https://www.php.net/distributions/php-8.3.2.tar.gz"
contentsRoot: "php-8.3.2"
8.4.1:
linux:
- url: "https://www.php.net/distributions/php-8.4.1.tar.gz"
contentsRoot: "php-8.4.1"
56 changes: 56 additions & 0 deletions agent/native/building/dependencies/php84/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import os
import shutil

from conans import tools, ConanFile, AutoToolsBuildEnvironment

class PhpHeadersForPHP81Conan(ConanFile):
description = "PHP headers package required to build Elastic APM agent without additional PHP dependencies"
license = "The PHP License, version 3.01"
homepage = "https://php.net/"
url = "https://php.net/"
author = "pawel.filipczak@elastic.co"

settings = "os", "compiler", "build_type", "arch"
platform = "linux"

def init(self):
self.name = self.conan_data["name"]
self.version = self.conan_data["version"] # version of the package
self.php_version = self.conan_data["php_source_version"] # version of the PHP to build
self.source_temp_dir = "php-src"

def requirements(self):
self.requires("libxml2/2.9.9")
self.requires("sqlite3/3.29.0")

def source(self):
for source in self.conan_data["sources"][self.php_version][self.platform]:

if "contentsRoot" in source:
# small hack - it can't contain custom fields, so we're removing it from source (got an unexpected keyword argument)
contentRoot = source["contentsRoot"]
del source["contentsRoot"]
tools.get(**source)
os.rename(contentRoot, self.source_temp_dir)
else:
self.output.error("Could not find 'contentsRoot' in conandata.yml")
raise Exception("Could not find 'contentsRoot' in conandata.yml")

def build(self):
with tools.chdir(os.path.join(self.source_folder, self.source_temp_dir)):
buildEnv = AutoToolsBuildEnvironment(self)
envVariables = buildEnv.vars
envVariables['ac_cv_php_xml2_config_path'] = os.path.join(self.deps_cpp_info["libxml2"].rootpath, "bin/xml2-config")
envVariables['LIBXML_LIBS'] = os.path.join(self.deps_cpp_info["libxml2"].rootpath, self.deps_cpp_info["libxml2"].libdirs[0])
envVariables['LIBXML_CFLAGS'] = "-I{}".format(os.path.join(self.deps_cpp_info["libxml2"].rootpath, self.deps_cpp_info["libxml2"].includedirs[0]))
envVariables['SQLITE_LIBS'] = os.path.join(self.deps_cpp_info["sqlite3"].rootpath, self.deps_cpp_info["sqlite3"].libdirs[0])
envVariables['SQLITE_CFLAGS'] = "-I{}".format(os.path.join(self.deps_cpp_info["sqlite3"].rootpath, self.deps_cpp_info["sqlite3"].includedirs[0]))
self.run("./buildconf --force")
buildEnv.configure(args=[""], vars=envVariables, build=False, host=False)

def package(self):
source = os.path.join(self.source_folder, self.source_temp_dir)
self.copy("*.h", src=source, dst='include', keep_path=True)

def package_id(self):
del self.info.settings.compiler.version
5 changes: 3 additions & 2 deletions agent/native/loader/code/phpdetection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ bool isThreadSafe() {

std::tuple<std::string_view, int, bool> getZendModuleApiVersion(std::string_view zendVersion) {
using namespace std::string_view_literals;
constexpr size_t knownVersionsCount = 16;
constexpr size_t knownVersionsCount = 17;

constexpr std::array<std::tuple<std::string_view, int, bool>, knownVersionsCount> knownPhpVersions {{
{"4.4"sv, 20240924, true}, // PHP 8.4
{"4.3"sv, 20230831, true}, // PHP 8.3
{"4.2"sv, 20220829, true}, // PHP 8.2
{"4.1"sv, 20210902, true}, // PHP 8.1
Expand Down Expand Up @@ -91,4 +92,4 @@ std::tuple<std::string_view, int, bool> getZendModuleApiVersion(std::string_view



}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{ "name": "Sergey Kleyman" }
],
"require": {
"php": "^7.2||8.0.*||8.1.*||8.2.*||8.3.*",
"php": "^7.2||8.0.*||8.1.*||8.2.*||8.3.*||8.4.*"
"ext-json": "*",
"ext-pcntl": "*",
"psr/log": "^1.0"
Expand Down
2 changes: 1 addition & 1 deletion docs/setup.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ NOTE: Experimentally, we also provide packages for the ARM64 architecture - plea

[discrete]
==== PHP
The agent supports PHP versions 7.2-8.3.
The agent supports PHP versions 7.2-8.4.

[discrete]
==== curl
Expand Down
2 changes: 1 addition & 1 deletion docs/supported-technologies.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Experimentally, we also provide packages for the ARM64 architecture - please not
[[supported-php-versions]]
=== PHP versions

The agent supports PHP versions 7.2-8.3.
The agent supports PHP versions 7.2-8.4.

[float]
[[unsupported-php-sapis]]
Expand Down
5 changes: 3 additions & 2 deletions packaging/post-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,12 @@ function is_php_supported() {
[ "${PHP_MAJOR_MINOR}" == "8.0" ] || \
[ "${PHP_MAJOR_MINOR}" == "8.1" ] || \
[ "${PHP_MAJOR_MINOR}" == "8.2" ] || \
[ "${PHP_MAJOR_MINOR}" == "8.3" ]
[ "${PHP_MAJOR_MINOR}" == "8.3" ] || \
[ "${PHP_MAJOR_MINOR}" == "8.4" ]
then
return 0
else
echo 'Failed. The supported PHP versions are 7.2-8.3.'
echo 'Failed. The supported PHP versions are 7.2-8.4.'
return 1
fi
}
Expand Down
38 changes: 38 additions & 0 deletions packaging/test/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
version: "3"
services:
deb-fpm-php84:
image: elasticobservability/apm-agent-php-dev:packages-test-deb-fpm-php-8.4-0.0.1
build:
context: ubuntu
dockerfile: fpm/Dockerfile
args:
- PHP_VERSION=8.4
- SEL_DISTRO=bullseye
deb-fpm-php83:
image: elasticobservability/apm-agent-php-dev:packages-test-deb-fpm-php-8.3-0.0.1
build:
Expand Down Expand Up @@ -54,6 +62,14 @@ services:



deb-apache-php84:
image: elasticobservability/apm-agent-php-dev:packages-test-deb-apache-php-8.4-0.0.1
build:
context: ubuntu
dockerfile: apache/Dockerfile
args:
- PHP_VERSION=8.4
- SEL_DISTRO=bullseye
deb-apache-php83:
image: elasticobservability/apm-agent-php-dev:packages-test-deb-apache-php-8.3-0.0.1
build:
Expand Down Expand Up @@ -106,6 +122,14 @@ services:
- PHP_VERSION=7.2


deb-php84:
image: elasticobservability/apm-agent-php-dev:packages-test-deb-php-8.4-0.0.1
build:
context: ubuntu
dockerfile: Dockerfile
args:
- PHP_VERSION=8.4
- SEL_DISTRO=bullseye
deb-php83:
image: elasticobservability/apm-agent-php-dev:packages-test-deb-php-8.3-0.0.1
build:
Expand Down Expand Up @@ -157,6 +181,13 @@ services:
args:
- PHP_VERSION=7.2

rpm-php84:
image: elasticobservability/apm-agent-php-dev:packages-test-rpm-php-8.4-0.0.3
build:
context: centos
dockerfile: Dockerfile
args:
- PHP_VERSION=8.4
rpm-php83:
image: elasticobservability/apm-agent-php-dev:packages-test-rpm-php-8.3-0.0.3
build:
Expand Down Expand Up @@ -207,6 +238,13 @@ services:
args:
- PHP_VERSION=7.2

apk-php83:
image: elasticobservability/apm-agent-php-dev:packages-test-apk-php-8.4-0.0.1
build:
context: alpine
dockerfile: Dockerfile
args:
- PHP_VERSION=8.4
apk-php83:
image: elasticobservability/apm-agent-php-dev:packages-test-apk-php-8.3-0.0.1
build:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ final class GenerateUnpackScriptsTest extends ComponentTestCaseBase implements L
private const PHP_VERSION_7_4 = '7.4';
// Make sure list of PHP versions supported by the Elastic APM PHP Agent is in sync.
// See the comment in .ci/shared.sh
private const SUPPORTED_PHP_VERSIONS = ['7.2', '7.3', self::PHP_VERSION_7_4, '8.0', '8.1', '8.2', '8.3'];
private const SUPPORTED_PHP_VERSIONS = ['7.2', '7.3', self::PHP_VERSION_7_4, '8.0', '8.1', '8.2', '8.3', '8.4'];

private const LINUX_PACKAGE_TYPE_DEB = 'deb';
private const LINUX_PACKAGE_TYPE_RPM = 'rpm';
Expand Down

0 comments on commit ae53f5d

Please sign in to comment.