首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >使用PHP-Windows-Builder 构建PHP和扩展入门指南

使用PHP-Windows-Builder 构建PHP和扩展入门指南

作者头像
Tinywan
发布于 2024-03-20 13:15:36
发布于 2024-03-20 13:15:36
18600
代码可运行
举报
文章被收录于专栏:开源技术小栈开源技术小栈
运行总次数:0
代码可运行

上一章节大概介绍了一下 是什么?了解更多请点击一下链接查看。这篇着重强调一下怎么正确使用。

Fork 官方仓库

官方仓库地址:https://github.com/php/php-windows-builder

流水线配置

官方默认配置位于你的Github项目仓库.github/workflows/php.yml,这里我们直接新建一个 https://github.com/Tinywan/php-windows-builder/actions

php8.3.2.yml

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
name: Build PHP 8.3.2
on:
  release:
    types: [published]
jobs:
  php:
    strategy:
      matrix:
        arch: x64
        ts: nts
    runs-on: windows-2019
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Build
        uses: ./php
        with:
          php-version: ${{ github.event.inputs.php-version }}
          arch: ${{ matrix.arch }}
          ts: ${{ matrix.ts }}

  release:
    runs-on: ubuntu-latest
    steps:
      - name: Upload artifact to the release
        uses: php/php-windows-builder/release@v1
        with:
          release: 8.3.2
          token: ${{ secrets.PHP_TOKEN }}

注意配置:

  • PHP 版本:8.3.2
  • 架构arch:x64
  • 线程安全:nts

构建PHP

运行流水线

环境监测

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
Run actions/checkout@v4
  with:
    repository: Tinywan/php-windows-builder
    token: ***
    ssh-strict: true
    persist-credentials: true
    clean: true
    sparse-checkout-cone-mode: true
    fetch-depth: 1
    fetch-tags: false
    show-progress: true
    lfs: false
    submodules: false
    set-safe-directory: true
Syncing repository: Tinywan/php-windows-builder
Getting Git version info
Temporarily overriding HOME='D:\a\_temp\f932e9ec-2aae-4f93-a890-821934d7acaa' before making global git config changes
Adding repository directory to the temporary git global config as a safe directory
"C:\Program Files\Git\bin\git.exe" config --global --add safe.directory D:\a\php-windows-builder\php-windows-builder
Deleting the contents of 'D:\a\php-windows-builder\php-windows-builder'
Initializing the repository
Disabling automatic garbage collection
Setting up auth
Fetching the repository
Determining the checkout info
Checking out the ref
"C:\Program Files\Git\bin\git.exe" log -1 --format='%H'
'120c092ef7c71be9ecca3a5f79c2ae5d659ca0d0'

正式构建

这里比较漫长,请耐心等待哦!

终于构建结束啦!

下载构建好的包

下载地址:https://github.com/Tinywan/php-windows-builder/actions/runs/8282409968

解压:php-8.3.2-nts-Win32-vs16-x64.zip

查看PHP版本

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
$ ./php.exe -v
PHP 8.3.2 (cli) (built: Mar 14 2024 14:42:01) (NTS Visual C++ 2019 x64)
Copyright (c) The PHP Group
Zend Engine v4.3.2, Copyright (c) Zend Technologies

查看PHP扩展

构建PHP扩展

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
name: Build PHP Extension
on:
  workflow_dispatch:
    inputs:
      extension_url:
        description: 'Extension URL'
        required: true
      extension_ref:
        description: 'Extension ref'
        required: true
jobs:
  get-extension-matrix:
    runs-on: ubuntu-latest
    outputs:
      matrix: ${{ steps.extension-matrix.outputs.matrix }}
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Get the extension matrix
        id: extension-matrix
        uses: ./extension-matrix
        with:
          extension-url: ${{ inputs.extension_url }}
          extension-ref: ${{ inputs.extension_ref }}
          arch-list: 'x64, x86'
          ts-list: 'nts, ts'

  extension:
    needs: get-extension-matrix
    runs-on: ${{ matrix.os }}
    strategy:
      matrix: ${{fromJson(needs.get-extension-matrix.outputs.matrix)}}
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Build the extension
        uses: ./extension
        with:
          extension-url: ${{ inputs.extension_url }}
          extension-ref: ${{ inputs.extension_ref }}
          php-version: ${{ matrix.php-version }}
          arch: ${{ matrix.arch }}
          ts: ${{ matrix.ts }}

  artifacts:
    runs-on: ubuntu-latest
    needs: extension
    steps:
      - name: Upload artifacts
        uses: actions/upload-artifact/merge@v4
        with:
          name: artifacts
          delete-merged: true

构建结果

点击下载artifacts构建好的扩展包Xdebug,解压后

随便解压一个php_xdebug-3.3.1-8.1-nts-vs16-x64.zip 看看,你想要的php_xdebug.dll就已经在里面啦!

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2024-03-15,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 开源技术小栈 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
本文部分代码块支持一键运行,欢迎体验
本文部分代码块支持一键运行,欢迎体验