Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 133 additions & 0 deletions .github/workflows/debian-packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# Debian packaging build lane.
#
# Builds the phpr Debian packages (php-rust/debian) on the same distro
# the packages target and publishes them as workflow artifacts:
# - phpr-cli_*_amd64.deb, phpr-server_*_amd64.deb
# - native source set (.dsc, .tar.xz) + .changes/.buildinfo
#
# This lane is deliberately SEPARATE from ci.yml (the build-and-test
# gate for main): it does not run unit tests (they live in ci.yml and
# in the local oracle gates) and it only reacts to the packaging branch.
#
# Toolchain stance (php-rust pins rustc/cargo 1.98.1):
# The lane builds on debian:trixie, whose rustc (1.85) can never
# satisfy the "rustc (>= 1.98)" Build-Depends. The PINNED toolchain
# therefore ALWAYS arrives via rustup — fetched with curl from the
# official https://sh.rustup.rs installer, never from the Debian
# archive — so the compiler follows the pin, not the suite. The
# resolved absolute toolchain pair is handed to dpkg-buildpackage
# via CARGO/RUSTC (debian/rules honours both). debian/rules strips
# ~/.cargo/bin from the build PATH, so rustup's proxy shims stay
# inert even in rustup mode.
#
# The workspace layout: the git repo ROOT contains php-rust/ (the cargo
# workspace + debian/). dpkg-buildpackage runs in php-rust/ and writes
# its artifacts (../) to the repo root.
name: debian-packages

on:
push:
branches: [debian-packaging]
workflow_dispatch:

permissions:
contents: read

defaults:
run:
working-directory: php-rust

concurrency:
group: debian-packages-${{ github.ref }}
cancel-in-progress: true

jobs:
build-packages:
runs-on: ubuntu-latest
# The packaging target distro. trixie's rustc is older than the
# pin (1.85 vs 1.98.1), so the compiler never comes from apt here:
# the pinned toolchain is rustup-installed in a later step.
container: docker.io/library/debian:trixie
timeout-minutes: 60
steps:
- uses: actions/checkout@v5

- name: Report build environment
run: |
head -2 /etc/os-release
dpkg --print-architecture

- name: Install build dependencies
# trixie cannot resolve "rustc (>= 1.98)" (debian/control), so
# apt-get build-dep is out: install the Build-Depends EXPLICITLY,
# MINUS rustc/cargo — the pinned toolchain arrives via rustup in
# the next step. libgd3/libtidy58 come along as runtime
# dependencies of the -dev packages, so the later `dpkg -i`
# smoke step needs no extra dependency resolution. lintian ships
# here too for the gate below.
run: |
apt-get update -qq
apt-get install -y --no-install-recommends \
dpkg-dev curl ca-certificates \
build-essential debhelper cmake pkgconf \
zlib1g-dev libxml2-dev libxslt1-dev libgd-dev libtidy-dev \
libclang-dev lintian

# Installs the pinned toolchain per the lane's policy and exposes
# the absolute paths via step outputs. rustup itself comes from
# the official installer (curl), the toolchain from the pin in
# rust-toolchain.toml.
- name: Install the pinned toolchain (rustup via curl)
id: toolchain
run: |
pinned=$(sed -n 's/^channel = "\(.*\)"/\1/p' rust-toolchain.toml)
echo "pinned: $pinned"
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
| sh -s -- -y --profile minimal --default-toolchain none
. "$HOME/.cargo/env"
rustup toolchain install "$pinned" --profile minimal
cargo_bin=$(rustup which --toolchain "$pinned" cargo)
rustc_bin=$(rustup which --toolchain "$pinned" rustc)
echo "cargo=$cargo_bin" >> "$GITHUB_OUTPUT"
echo "rustc=$rustc_bin" >> "$GITHUB_OUTPUT"
"$rustc_bin" --version
"$cargo_bin" --version
cat "$GITHUB_OUTPUT" | sed 's/^/resolved: /'

- name: Build packages
env:
CARGO: ${{ steps.toolchain.outputs.cargo }}
RUSTC: ${{ steps.toolchain.outputs.rustc }}
run: |
# -d (no check-builddeps): dpkg cannot see the rustup
# toolchain, and trixie's apt rustc could never satisfy
# ">= 1.98" anyway. Every other Build-Depend was installed
# explicitly in the earlier step; the lane was validated
# end-to-end on trixie (build, lintian gate, dpkg -i, both
# packaged smoke tests green).
dpkg-buildpackage -us -uc -d

- name: Lintian (fail on errors; warnings reported)
run: |
lintian --pedantic --fail-on error ../*.changes

# Installed-package smoke: the same tests autopkgtest would run on
# a real testbed (debian/tests/{cli,server}), executed as root in
# this container. dpkg -i needs no dependency resolution here: the
# build-dep step already installed every runtime library.
- name: Smoke test (installed packages)
run: |
dpkg -i ../phpr-cli_*_amd64.deb ../phpr-server_*_amd64.deb
debian/tests/cli
debian/tests/server

- name: Collect artifacts
run: |
ls -l ..
mkdir -p /tmp/out && cp ../*.deb ../*.dsc ../*.tar.xz ../*.changes ../*.buildinfo /tmp/out/

- uses: actions/upload-artifact@v4
with:
name: phpr-debian-packages-amd64
path: /tmp/out/*
if-no-files-found: error
11 changes: 11 additions & 0 deletions php-rust/debian/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Packaging build state (dh_* staging trees and generated bookkeeping):
# regenerable on every dpkg-buildpackage run, never committed.
/.debhelper/
/debhelper-build-stamp
/files
/*.substvars
/*.debhelper.log
/*.debhelper
/phpr-cli/
/phpr-server/
/tmp/
16 changes: 16 additions & 0 deletions php-rust/debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
phpr (0.1.0) unstable; urgency=medium

* Initial Debian packaging of the php-rust workspace.
* phpr-cli: ships /usr/bin/phpr; provides the Debian virtual packages
php-cli and php8.5-cli (plus php-json); conflicts with and replaces
php8.5-cli; registers /usr/bin/php via update-alternatives at
priority 85. No php.ini handling (the engine reads none), no
-v/-m/-i/-l switches yet; documented in README.Debian.
* phpr-server: ships /usr/bin/php-server (union build, cli-server +
axum-server features) and a hardened systemd service running as
www-data, configured via /etc/default/phpr-server. Makes no
php-fpm claim (no FastCGI).
* Tests: installed-package smoke tests via autopkgtest (CLI + server).
* No debian/watch: upstream develops in git without release tarballs.

-- Francesco Tinti <francesco.tinti@activemind.it> Sun, 22 Nov 2026 12:00:00 +0100
68 changes: 68 additions & 0 deletions php-rust/debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
Source: phpr
Section: php
Priority: optional
Maintainer: Francesco Tinti <francesco.tinti@activemind.it>
Standards-Version: 4.7.4
# Toolchain note (trixie): the rustc/cargo Build-Depends below pin the
# compiler for suites that ship a matching rustc via apt (the
# verification host runs Debian forky/sid). Debian trixie ships
# rustc 1.85 and can never satisfy ">= 1.98": a trixie build (the CI
# lane in .github/workflows/debian-packages.yml) installs these
# Build-Depends explicitly MINUS rustc/cargo, installs the pinned
# toolchain with rustup (https://sh.rustup.rs, fetched with curl) and
# builds with `dpkg-buildpackage -d`, passing the absolute toolchain
# pair via CARGO/RUSTC (debian/rules honours both).
Build-Depends: debhelper-compat (= 13),
rustc (>= 1.98),
cargo (>= 1.98),
cmake,
pkgconf,
zlib1g-dev,
libxml2-dev,
libxslt1-dev,
libgd-dev,
libtidy-dev,
libclang-dev
Rules-Requires-Root: no
Homepage: https://github.com/francescotinti/php-rust
Vcs-Git: https://github.com/francescotinti/php-rust.git
Vcs-Browser: https://github.com/francescotinti/php-rust

Package: phpr-cli
Architecture: any
Depends: libgd3, libtidy58, ${shlibs:Depends}, ${misc:Depends}
Provides: php-cli, php8.5-cli, php-json, php8.5-json
Conflicts: php8.5-cli
Replaces: php8.5-cli
Description: command-line interpreter for PHP scripts (Rust reimplementation)
phpr is a from-scratch reimplementation of PHP 8.5.7 in Rust (the
php-rust project). It runs unmodified PHP scripts with the same
observable behaviour as the reference interpreter, byte-for-byte for
everything that lands in PHP strings and output streams.
.
This package installs the /usr/bin/phpr interpreter and registers it
with update-alternatives as /usr/bin/php (priority 85, the 8.5 slot),
so tooling that invokes "php" keeps working. It can coexist with the
packaged php8.4-cli / php8.6-cli; it conflicts with php8.5-cli, whose
package name it also Provides.
.
Known gaps vs the reference CLI (deliberate, documented in
/usr/share/doc/phpr-cli/README.Debian): no php.ini is read, the
-v/-m/-i/-l/-w/--ini switches are not implemented, and php8.5-*
extension modules from the archive have no effect on phpr.

Package: phpr-server
Architecture: any
Depends: libgd3, libtidy58, ${shlibs:Depends}, ${misc:Depends}
Description: standalone PHP web server (php -S work-alike)
php-server is the web SAPI of the php-rust project: a standalone HTTP
server (a work-alike of "php -S") that serves a document root and
executes PHP requests via the phpr engine, in two modes: the
sequential cli-server mode and an Axum-based multi-worker mode
(shared FIFO queue, one fresh VM per request).
.
This is NOT FastCGI: it does not speak the FPM protocol and therefore
does not replace php8.5-fpm behind nginx/Apache fastcgi_pass. Front
it with any reverse proxy over plain HTTP instead. The service runs
as www-data and is configured through /etc/default/phpr-server
(host, port, document root, worker count).
69 changes: 69 additions & 0 deletions php-rust/debian/copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: php-rust
Upstream-Contact: Francesco Tinti <francesco.tinti@activemind.it>
Source: https://github.com/francescotinti/php-rust

Files: *
Copyright: 2026 Francesco Tinti
License: PHP-3.01

Files: debian/*
Copyright: 2026 Francesco Tinti
License: PHP-3.01

License: PHP-3.01
--------------------------------------------------------------------
The PHP License, version 3.01
Copyright (c) 1999 - 2024 The PHP Group. All rights reserved.
--------------------------------------------------------------------
.
Redistribution and use in source and binary forms, with or without
modification, is permitted provided that the following conditions
are met:
.
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
.
3. The name "PHP" must not be used to endorse or promote products
derived from this software without prior written permission. For
written permission, please contact group@php.net.
.
4. Products derived from this software may not be called "PHP", nor
may "PHP" appear in their name, without prior written permission
from group@php.net. You may indicate that your software works in
conjunction with PHP by saying "Foo for PHP" instead of calling
it "PHP Foo" or "phpfoo"
.
5. The PHP Group may publish revised and/or new versions of the
license from time to time. Each version will be given a
distinguishing version number. Once covered code has been
published under a particular version of the license, you may
always continue to use it under the terms of that version. You
may also choose to use such covered code under the terms of any
subsequent version of the license published by the PHP Group. No
one other than the PHP Group has the right to modify the terms
applicable to covered code created under this License.
.
6. Redistributions of any form whatsoever must retain the following
acknowledgment:
"This product includes PHP software, freely available from
<http://www.php.net/software/>".
.
THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND
ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP
DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------
70 changes: 70 additions & 0 deletions php-rust/debian/man/php-server.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
.TH PHP-SERVER 1 "November 2026" "php-rust" "User Commands"
.SH NAME
php-server \- standalone PHP web server (php \-S work-alike)
.SH SYNOPSIS
.B php-server
.RI [ options ]
.RI [ ROUTER.php ]
.SH DESCRIPTION
.B php-server
is the web SAPI of the php-rust project: a standalone HTTP server that
serves a document root and executes PHP requests through the phpr
engine. It speaks plain HTTP \(em it is
.B not
a FastCGI backend and does not implement the FPM protocol, so it
cannot replace php*-fpm behind nginx/Apache
.BR fastcgi_pass .
Front it with any reverse proxy over HTTP instead.
.PP
Two modes are selected at startup:
.TP
.B cli-server (default)
Byte-faithful work-alike of the reference
.BR "php \-S" :
one thread, sequential request handling, honours a
.I ROUTER.php
router script.
.TP
.B \-\-axum
Axum front end with a pool of N OS worker threads sharing one FIFO
queue; each request runs on a fresh VM (no state leaks between
requests). Note: a router script is
.B not
honoured in this mode; single-process SIGTERM/SIGINT drains cleanly.
.SH OPTIONS
.TP
.BI \-\-host " HOST"
Listen address (default: 127.0.0.1).
.TP
.BI \-\-port " PORT"
Listen port (default: 8080).
.TP
.BI \-\-docroot " DIR" | " \-t DIR"
Document root; resolved to its canonical path and made the process
working directory (default: current directory).
.TP
.BI \-\-workers " N"
Worker count in \-\-axum mode; 0 means one worker per CPU (ignored by
the cli-server mode).
.TP
.B \-\-tier0
Axum-only diagnostic baseline: static 200 response, no pool, no VM.
.TP
.B \-\-help
Usage summary.
.SH SYSTEMD
On Debian the
.B phpr\-server.service
unit runs this program in \-\-axum mode as the
.B www\-data
user, with settings taken from
.IR /etc/default/phpr\-server
(PHPR_HOST, PHPR_PORT, PHPR_DOCROOT, PHPR_WORKERS). Enabled by default
\(em see
.BR systemctl (1).
.SH SEE ALSO
The CLI interpreter:
.BR phpr (1).
.SH AUTHOR
php-rust by Francesco Tinti. This manual page was written for the
Debian project.
Loading