Skip to content

Rewrite to be based on php-build#200

Open
Rusydy wants to merge 63 commits into
asdf-community:masterfrom
Rusydy:refactor-with-php-build
Open

Rewrite to be based on php-build#200
Rusydy wants to merge 63 commits into
asdf-community:masterfrom
Rusydy:refactor-with-php-build

Conversation

@Rusydy

@Rusydy Rusydy commented Dec 11, 2025

Copy link
Copy Markdown
Contributor

TLDR; to solve #198, #72 and #194

This pull request introduces significant improvements to the PHP plugin's development workflow, documentation, and compatibility with modern dependencies. The most notable changes include a complete overhaul of the GitHub Actions CI workflow for better cross-platform and legacy PHP support, new documentation for manual local testing, compatibility patches for ICU 74 and libxml2 2.12, and a script for installing OpenSSL 1.1. Additionally, a new submodule for php-build is added to the repository.

CI/CD and Development Workflow Improvements

  • Major rewrite of .github/workflows/workflow.yml to use a single, matrix-based job supporting both Ubuntu and macOS, legacy and modern PHP versions, with improved dependency management and diagnostics. Adds linting and formatting jobs with more robust dependency installation and caching.
  • Adds vendor/php-build as a submodule, ensuring consistent build tooling. (.gitmodules)

Documentation Enhancements

  • Expands README.md with clearer installation, update, and usage instructions for the asdf PHP plugin.
  • Adds docs/local-testing-manually.md with detailed, step-by-step guides for installing, uninstalling, and troubleshooting various PHP versions locally, including custom build flags and log monitoring.

Compatibility and Build Fixes

  • Adds patch for PHP 7.4 to fix compatibility with ICU 74 (patches/php-7.4-icu-74-compat.patch).
  • Adds patch for PHP 8.0 to fix compatibility with ICU 74 (patches/php-8.0-icu-74-compat.patch).
  • Adds patch for PHP 8.0 to fix compatibility with libxml2 2.12 (patches/php-8.0-libxml2-2.12-compat.patch).

Utility Scripts

  • Introduces lib/install-openssl11.sh, a robust script for building and installing OpenSSL 1.1 locally, with dependency checks, colored output, and instructions for environment configuration.

Note

Modernizes the plugin around php-build, expanding CI/test coverage and improving legacy compatibility.

  • Add vendor/php-build submodule and bin/post-plugin-add to auto-initialize it; new bin/latest-stable for resolving latest
  • Rewrite bin/install to drive php-build, auto-detect/auto-install OpenSSL 1.1 (lib/install-openssl11.sh), set compilers/flags for legacy PHP, install Composer, optional Xdebug, and patch definitions for ICU 74 and libxml2 2.12
  • Add runtime env tweaks in bin/exec-env to set LD_LIBRARY_PATH for OpenSSL 1.1 when required
  • Overhaul CI workflow to a single matrix job across Ubuntu/macOS and legacy/modern versions; add lint and format jobs
  • Add compatibility patches: patches/php-7.4-icu-74-compat.patch, patches/php-8.0-icu-74-compat.patch, patches/php-8.0-libxml2-2.12-compat.patch
  • Update README.md and add docs/local-testing-manually.md; add .gitmodules and expand .gitignore

Written by Cursor Bugbot for commit 3492506. This will update automatically on new commits. Configure here.

@Rusydy Rusydy requested a review from a team as a code owner December 11, 2025 08:09
@Rusydy Rusydy marked this pull request as draft December 11, 2025 08:23
@Rusydy

Rusydy commented Dec 11, 2025

Copy link
Copy Markdown
Contributor Author

Waiting for php-build/php-build#796 to be approved by php-build's maintainer

@Rusydy

Rusydy commented Dec 17, 2025

Copy link
Copy Markdown
Contributor Author

Installation test of 7.4.14 on Almalinux 10

Screenshot 2025-12-17 at 22 26 39

Installation test of 8.0.0 on Almalinux 10

Screenshot 2025-12-17 at 21 26 22

Installation test of 8.3.29 on Almalinux 10

Screenshot 2025-12-26 at 04 12 28

@Rusydy Rusydy marked this pull request as ready for review December 25, 2025 21:21
…d/compile

- Replace custom download and compilation logic with php-build
- Add automatic OpenSSL 1.1 compatibility detection and installation
- Add compiler warning fixes for modern GCC versions
- Add automated Composer installation with signature verification
- Add Xdebug installation support
- Add comprehensive patches for PHP 7.4 and 8.0 compatibility
- Add post-plugin-add hook for automatic php-build initialization
- Add latest-stable version resolution
- Add extensive documentation and testing instructions
- Add support for all php-build environment variables and options

This addresses build failures on modern systems and provides a more
maintainable and feature-rich PHP installation experience.
…9 examples

- Add comprehensive installation examples for latest stable version
- Include verbose installation options and custom compiler flags
- Add monitoring instructions with log file tailing
- Improve command consistency using 'asdf plugin add php $(pwd)'
- Document verification steps for successful installations
@Rusydy Rusydy force-pushed the refactor-with-php-build branch from a1f1048 to 8e37fe6 Compare December 25, 2025 21:26
- Remove spaces around redirection operators (&>/dev/null, >/dev/null, >>, etc.)
- Conform to shfmt standard formatting rules (-s -i 2 -ci)
- Resolves CI format check failure
- Fix SC2155: Separate variable declaration and assignment to avoid masking return codes
- Fix SC2086: Add proper quoting for variables to prevent word splitting
- Fix SC2034: Remove unused php_status variable
- Apply fixes to bin/install and bin/exec-env
- All shellcheck warnings resolved while maintaining functionality
@Rusydy Rusydy force-pushed the refactor-with-php-build branch from c70d153 to 3b506dd Compare December 25, 2025 22:01
Replace manual asdf/PHP setup with asdf-vm/actions/plugin-test and
remove ad-hoc asdf install and plugin steps. Add a non-fatal Composer
version check and initialize git submodules earlier, setting executable
permissions. Use asdf-vm/actions/setup and asdf-vm/actions/install to
provide shfmt, shellcheck and make, and simplify lint/format commands.
Use apt-get to install shellcheck and make and download shfmt v3.8.0
Drop asdf-vm actions from workflow
Provide giturl and gitref environment inputs so the PHP setup action can
access the current repository and checkout the exact commit.
Add asdf setup action and install the plugin from the current checkout,
then install and set the PHP version globally. Increase the test step
timeout to 30 minutes.
@Rusydy Rusydy force-pushed the refactor-with-php-build branch 4 times, most recently from 9c7a281 to a2774e5 Compare December 26, 2025 02:31
@Rusydy

Rusydy commented Jan 4, 2026

Copy link
Copy Markdown
Contributor Author

I am currently focused on PHP 8.0.0 installation on macOS

Rusydy added 4 commits January 4, 2026 20:10
- Replace all sed 'a' (append) commands with portable awk equivalents
- Fixes macOS BSD sed error: 'command a expects \ followed by text'
- Remove unused SED_INPLACE variable
- Maintain identical patch insertion functionality
- Cross-platform compatible (macOS, Linux, BSD)
- Add OS detection for platform-specific build flags
- Configure BZip2 and libiconv paths for macOS using Homebrew
- Remove incompatible Linux linker flags (--no-as-needed) on macOS
- Set proper LDFLAGS and CPPFLAGS for Homebrew library paths
- Fixes BZip2 'Please reinstall the BZip2 distribution' error on macOS
@OliverWich

Copy link
Copy Markdown

Excited to finally have asdf (and thus mise) be able to install php properly again.

Thanks for your work, looking forward to when this reaches master, keep it up!

@Rusydy

Rusydy commented Jan 19, 2026

Copy link
Copy Markdown
Contributor Author

I am still working on PHP 8.0.0 installation on macOS

below is my note for tracking down the issue using plainuml

@startuml
start

:Pemeriksaan Platform & Arsitektur;
:Inisialisasi Jalur php-build Internal;
:Muat Definisi Versi;
    if (Versi Tersedia?) is (<color:black>yes) then
    :Panggil php-build Executable;
    :\t\t\t\t\t\t; <<timeEvent>>
        if (Kompilasi Berhasil?) is (<color:black>yes) then
            :Mapping Binary ke Path ASDF;
        else (<color:red>no)
            :Tampilkan Log Error dari php-build;
            stop
        endif
        :Registrasi Shims;
        stop
    else (<color:red>no)
        :Tampilkan Pesan Error;
        stop
    endif
@enduml

2026 January 24; turns out the error is in php-build, I need to work on php-build first

@OliverWich

Copy link
Copy Markdown

If I can provide any help, I am happy to help / test on Arch Linux.

Just let me know what to do :)

@Rusydy

Rusydy commented Jan 24, 2026

Copy link
Copy Markdown
Contributor Author

Hi @OliverWich

Yes, I would like to have your perspective about these changes on Arch Linux.
You can see the step by step to test it on docs/local-testing-manually.md
Currently, I only test them on macOS, Alma Linux and Ubuntu

@Rusydy

Rusydy commented Feb 10, 2026

Copy link
Copy Markdown
Contributor Author

One of my PR, php-build/php-build#796 (comment), has been merged
I will continue to investigate

and I will add CI for PHP 8.5.2 which released in January 2026

@Rusydy-Mekari Rusydy-Mekari force-pushed the refactor-with-php-build branch from 61b7e04 to 509aff4 Compare April 15, 2026 06:03
Rusydy-Mekari and others added 7 commits April 16, 2026 09:31
Update ext/intl/config.m4 to compile with C++17.
ICU 74+ headers use C++17 features (enable_if_t, void_t, is_same_v,
if constexpr), so PHP_CXX_COMPILE_STDCXX was bumped from 11 to 17
Add -Wno-int-conversion to CFLAGS for PHP 7.4 and 8.0.x to silence int
conversion warnings.
Append to PHP_BUILD_CONFIGURE_OPTS and LDFLAGS instead of only setting
defaults so existing values are preserved.
On macOS enable CXXFLAGS -std=c++17 -stdlib=libc++
-DU_USING_ICU_NAMESPACE and prefer Homebrew's libgd via
--with-external-gd when available.
Inject an intl C++17 patch into php-build definitions to require C++17
for ext/intl so ICU 74+/78+ headers compile correctly.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 issues found across 19 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="docs/local-testing-manually.md">

<violation number="1" location="docs/local-testing-manually.md:46">
P3: Shell prompt prefix in code block makes the command non-copy-pasteable. Remove the prompt prefix so users can copy the command directly.</violation>
</file>

<file name="tests/install_concurrency.bats">

<violation number="1" location="tests/install_concurrency.bats:11">
P2: sed extraction pattern in setup() anchors to comment text that could change independently of the function.</violation>
</file>

<file name="README.md">

<violation number="1" location="README.md:71">
P2: `asdf set php latest` sets the version in the current directory's `.tool-versions`, NOT globally. Use `asdf set -u php latest` to write to `~/.tool-versions`.</violation>
</file>

<file name="tests/install_dependencies.bats">

<violation number="1" location="tests/install_dependencies.bats:47">
P2: setup() uses sed range patterns to extract functions from bin/install, which breaks if internal whitespace, comment lines, or brace positioning changes. Consider sourcing the whole file and calling functions directly, or refactoring the functions into a separate library file for testing.</violation>
</file>

Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.

Re-trigger cubic

export TEST_TEMP_DIR="$(mktemp -d)"

# Extract and source only the target function to avoid install script side effects
sed -n '/^# php-build does not read ASDF_CONCURRENCY/,/^}$/p' \

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: sed extraction pattern in setup() anchors to comment text that could change independently of the function.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At tests/install_concurrency.bats, line 11:

<comment>sed extraction pattern in setup() anchors to comment text that could change independently of the function.</comment>

<file context>
@@ -0,0 +1,70 @@
+  export TEST_TEMP_DIR="$(mktemp -d)"
+
+  # Extract and source only the target function to avoid install script side effects
+  sed -n '/^# php-build does not read ASDF_CONCURRENCY/,/^}$/p' \
+    "${PLUGIN_DIR}/bin/install" > "${TEST_TEMP_DIR}/function.sh"
+  source "${TEST_TEMP_DIR}/function.sh"
</file context>

Comment thread README.md
asdf install php latest

# Set a version globally (in ~/.tool-versions)
asdf set php latest

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: asdf set php latest sets the version in the current directory's .tool-versions, NOT globally. Use asdf set -u php latest to write to ~/.tool-versions.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At README.md, line 71:

<comment>`asdf set php latest` sets the version in the current directory's `.tool-versions`, NOT globally. Use `asdf set -u php latest` to write to `~/.tool-versions`.</comment>

<file context>
@@ -7,71 +7,191 @@ _Original version of this plugin created by
+asdf install php latest
+
+# Set a version globally (in ~/.tool-versions)
+asdf set php latest
+
+# Or set locally for a project (in ./.tool-versions)
</file context>
Suggested change
asdf set php latest
asdf set -u php latest


# resolve_brew_package_prefix must be sourced before setup_macos_dependencies
# because setup_macos_dependencies calls it at runtime
sed -n '/^# Homebrew keg-only packages/,/^}$/p' "${PLUGIN_DIR}/bin/install" > "${TEST_TEMP_DIR}/function.sh"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: setup() uses sed range patterns to extract functions from bin/install, which breaks if internal whitespace, comment lines, or brace positioning changes. Consider sourcing the whole file and calling functions directly, or refactoring the functions into a separate library file for testing.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At tests/install_dependencies.bats, line 47:

<comment>setup() uses sed range patterns to extract functions from bin/install, which breaks if internal whitespace, comment lines, or brace positioning changes. Consider sourcing the whole file and calling functions directly, or refactoring the functions into a separate library file for testing.</comment>

<file context>
@@ -0,0 +1,194 @@
+
+  # resolve_brew_package_prefix must be sourced before setup_macos_dependencies
+  # because setup_macos_dependencies calls it at runtime
+  sed -n '/^# Homebrew keg-only packages/,/^}$/p' "${PLUGIN_DIR}/bin/install" > "${TEST_TEMP_DIR}/function.sh"
+  sed -n '/^# Configure macOS-specific dependencies for all PHP versions$/,/^}$/p' "${PLUGIN_DIR}/bin/install" >> "${TEST_TEMP_DIR}/function.sh"
+  source "${TEST_TEMP_DIR}/function.sh"
</file context>

asdf plugin remove php
asdf plugin add php $(pwd)
asdf install php 8.3.29
➜ ~ asdf set php 8.3.29

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: Shell prompt prefix in code block makes the command non-copy-pasteable. Remove the prompt prefix so users can copy the command directly.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At docs/local-testing-manually.md, line 46:

<comment>Shell prompt prefix in code block makes the command non-copy-pasteable. Remove the prompt prefix so users can copy the command directly.</comment>

<file context>
@@ -0,0 +1,103 @@
+asdf plugin remove php
+asdf plugin add php $(pwd)
+asdf install php 8.3.29
+➜  ~ asdf set php 8.3.29
+# the return should be like
+# ➜  ~ php -v
</file context>
Suggested change
➜ ~ asdf set php 8.3.29
asdf set php 8.3.29

@Rusydy Rusydy force-pushed the refactor-with-php-build branch from 69410ef to 7868cbf Compare June 28, 2026 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

5 participants