Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
1 change: 0 additions & 1 deletion .github/workflows/static.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ jobs:
targets: static-builder-gnu
set: |
${{ (github.event_name == 'pull_request' || matrix.platform == 'linux/arm64') && 'static-builder-gnu.args.NO_COMPRESS=1' || '' }}
static-builder-gnu.args.BUILD_PACKAGES=1
*.tags=
*.platform=${{ matrix.platform }}
*.cache-from=type=gha,scope=${{ needs.prepare.outputs.ref || github.ref }}-static-builder-gnu
Expand Down
81 changes: 60 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,49 +16,69 @@ FrankenPHP can also be used as a standalone Go library to embed PHP in any app u

## Getting Started

### Standalone Binary

We provide static FrankenPHP binaries for Linux and macOS
containing [PHP 8.4](https://www.php.net/releases/8.4/en.php) and most popular PHP extensions.

On Windows, use [WSL](https://learn.microsoft.com/windows/wsl/) to run FrankenPHP.

[Download FrankenPHP](https://github.com/php/frankenphp/releases) or copy this line into your
terminal to automatically install the version appropriate for your platform:
### Install Script

You can copy this line into your terminal to automatically
install an appropriate version for your platform:

```console
curl https://frankenphp.dev/install.sh | sh
mv frankenphp /usr/local/bin/
```

To serve the content of the current directory, run:
### Standalone Binary

We provide static FrankenPHP binaries for development purposes on Linux and macOS
containing [PHP 8.4](https://www.php.net/releases/8.4/en.php) and most popular PHP extensions.

[Download FrankenPHP](https://github.com/php/frankenphp/releases)

### RPM Packages

We offer RPM packages for all systems using `dnf`. To install, run:

```console
frankenphp php-server
sudo dnf install https://rpm.henderkes.com/static-php-1-0.noarch.rpm
sudo dnf module enable php-zts:static-8.4 # 8.2-8.5 available
sudo dnf install frankenphp
# to install extensions:
sudo dnf install php-zts-xdebug
# if an extension is not available by default, install it with pie
sudo dnf install php-zts-devel
sudo pie install asgrim/example-pie-extension --with-php-config=php-config-zts
```

You can also run command-line scripts with:
### DEB Packages

We offer DEB packages for all systems using `apt`. To install, run:

```console
frankenphp php-cli /path/to/your/script.php
sudo curl -fsSL https://key.henderkes.com/static-php.gpg -o /usr/share/keyrings/static-php.gpg && \
echo "deb [signed-by=/usr/share/keyrings/static-php.gpg] https://deb.henderkes.com/ stable main" | sudo tee /etc/apt/sources.list.d/static-php.list && \
sudo apt update
sudo apt install frankenphp
# to install extensions:
sudo apt install php-zts-xdebug
# if an extension is not available by default, install it with pie
sudo apt install php-zts-devel
sudo pie install asgrim/example-pie-extension --with-php-config=php-config-zts
```

### Docker
### Usage

Alternatively, [Docker images](https://frankenphp.dev/docs/docker/) are available:
To serve the content of the current directory, run:

```console
docker run -v .:/app/public \
-p 80:80 -p 443:443 -p 443:443/udp \
dunglas/frankenphp
frankenphp php-server
```

Go to `https://localhost`, and enjoy!
You can also run command-line scripts with:

> [!TIP]
>
> Do not attempt to use `https://127.0.0.1`. Use `https://localhost` and accept the self-signed certificate.
> Use the [`SERVER_NAME` environment variable](docs/config.md#environment-variables) to change the domain to use.
```console
frankenphp php-cli /path/to/your/script.php
```

### Homebrew

Expand All @@ -76,6 +96,25 @@ To serve the content of the current directory, run:
frankenphp php-server
```

If you need extensions, you will have to install them with [pie](https://github.com/php/pie).

### Docker

Alternatively, [Docker images](https://frankenphp.dev/docs/docker/) are available:

```console
docker run -v .:/app/public \
-p 80:80 -p 443:443 -p 443:443/udp \
dunglas/frankenphp
```

Go to `https://localhost`, and enjoy!

> [!TIP]
>
> Do not attempt to use `https://127.0.0.1`. Use `https://localhost` and accept the self-signed certificate.
> Use the [`SERVER_NAME` environment variable](docs/config.md#environment-variables) to change the domain to use.

## Docs

- [Classic mode](https://frankenphp.dev/docs/classic/)
Expand Down
119 changes: 0 additions & 119 deletions build-packages.sh

This file was deleted.

4 changes: 3 additions & 1 deletion build-static.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ CURRENT_DIR=$(pwd)

arch="$(uname -m)"
os="$(uname -s | tr '[:upper:]' '[:lower:]')"
[ "$os" = "darwin" ] && os="mac"

# Supported variables:
# - PHP_VERSION: PHP version to build (default: "8.4")
Expand Down Expand Up @@ -202,8 +203,9 @@ for pkg in ${SPC_OPT_INSTALL_ARGS}; do
done
# shellcheck disable=SC2086
${spcCommand} download --with-php="${PHP_VERSION}" --for-extensions="${PHP_EXTENSIONS}" --for-libs="${PHP_EXTENSION_LIBS}" ${SPC_OPT_DOWNLOAD_ARGS}
export FRANKENPHP_SOURCE_PATH="${CURRENT_DIR}"
# shellcheck disable=SC2086
FRANKENPHP_SOURCE_DIR=${CURRENT_DIR} ${spcCommand} build --enable-zts --build-embed --build-frankenphp ${SPC_OPT_BUILD_ARGS} "${PHP_EXTENSIONS}" --with-libs="${PHP_EXTENSION_LIBS}"
${spcCommand} build --enable-zts --build-embed --build-frankenphp ${SPC_OPT_BUILD_ARGS} "${PHP_EXTENSIONS}" --with-libs="${PHP_EXTENSION_LIBS}"

cd ../..

Expand Down
6 changes: 2 additions & 4 deletions docs/performance.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,9 @@ especially when compiled in ZTS mode (thread-safe), which is required for Franke

Also, [some bugs only happen when using musl](https://github.com/php/php-src/issues?q=sort%3Aupdated-desc+is%3Aissue+is%3Aopen+label%3ABug+musl).

In production environments, we recommend using FrankenPHP linked against glibc.
In production environments, we recommend using FrankenPHP linked against glibc, compiled with an appropriate optimization level.

This can be achieved by using the Debian Docker images (the default), downloading the -gnu suffix binary from our [Releases](https://github.com/php/frankenphp/releases), or by [compiling FrankenPHP from sources](compile.md).

Alternatively, we provide static musl binaries compiled with [the mimalloc allocator](https://github.com/microsoft/mimalloc), which alleviates the problems in threaded scenarios.
This can be achieved by using the Debian Docker images, using our maintainers [.deb](https://debs.henderkes.com) or [.rpm](https://rpms.henderkes.com) packages, or by [compiling FrankenPHP from sources](compile.md).

## Go Runtime Configuration

Expand Down
60 changes: 47 additions & 13 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

set -e

SUDO=""
if [ "$(id -u)" -ne 0 ]; then
SUDO="sudo"
fi

if [ -z "${BIN_DIR}" ]; then
BIN_DIR=$(pwd)
fi
Expand All @@ -21,6 +26,46 @@ fi

case ${OS} in
Linux*)
if [ "${ARCH}" = "aarch64" ] || [ "${ARCH}" = "x86_64" ]; then
if command -v dnf >/dev/null 2>&1; then
echo "📦 Detected dnf. Installing FrankenPHP from RPM repository..."
if [ -n "${SUDO}" ]; then
echo "❗ Enter your password to grant sudo powers for package installation"
${SUDO} -v || true
fi
${SUDO} dnf -y install https://rpm.henderkes.com/static-php-1-0.noarch.rpm
${SUDO} dnf -y module enable php-zts:static-8.4 || true
${SUDO} dnf -y install frankenphp
echo
echo "🥳 FrankenPHP installed successfully"
echo
echo "⭐ If you like FrankenPHP, please give it a star on GitHub: ${italic}https://github.com/php/frankenphp${normal}"
exit 0
fi

if command -v apt >/dev/null 2>&1 || command -v apt-get >/dev/null 2>&1; then
echo "📦 Detected apt. Installing FrankenPHP from DEB repository..."
if [ -n "${SUDO}" ]; then
echo "❗ Enter your password to grant sudo powers for package installation"
${SUDO} -v || true
fi
${SUDO} sh -c 'curl -fsSL https://key.henderkes.com/static-php.gpg -o /usr/share/keyrings/static-php.gpg'
${SUDO} sh -c 'echo "deb [signed-by=/usr/share/keyrings/static-php.gpg] https://deb.henderkes.com/ stable main" > /etc/apt/sources.list.d/static-php.list'
if command -v apt >/dev/null 2>&1; then
${SUDO} apt update
${SUDO} apt -y install frankenphp
else
${SUDO} apt-get update
${SUDO} apt-get -y install frankenphp
fi
echo
echo "🥳 FrankenPHP installed successfully."
echo
echo "⭐ If you like FrankenPHP, please give it a star on GitHub: ${italic}https://github.com/php/frankenphp${normal}"
exit 0
fi
fi

case ${ARCH} in
aarch64)
THE_ARCH_BIN="frankenphp-linux-aarch64"
Expand Down Expand Up @@ -63,33 +108,22 @@ if [ -z "${THE_ARCH_BIN}" ]; then
exit 1
fi

SUDO=""

echo "📦 Downloading ${bold}FrankenPHP${normal} for ${OS}${GNU} (${ARCH}):"

# check if $DEST is writable and suppress an error message
touch "${DEST}" 2>/dev/null

# we need sudo powers to write to DEST
if [ $? -eq 1 ]; then
echo "❗ You do not have permission to write to ${italic}${DEST}${normal}, enter your password to grant sudo powers"
SUDO="sudo"
fi

if type "curl" >/dev/null 2>&1; then
curl -L --progress-bar "https://github.com/php/frankenphp/releases/latest/download/${THE_ARCH_BIN}" -o "${DEST}"
elif type "wget" >/dev/null 2>&1; then
${SUDO} wget "https://github.com/php/frankenphp/releases/latest/download/${THE_ARCH_BIN}" -O "${DEST}"
else
echo "❗ Please install ${italic}curl${normal} or ${italic}wget${normal} to download FrankenPHP"
exit 1
fi
curl -L --progress-bar "https://github.com/php/frankenphp/releases/latest/download/${THE_ARCH_BIN}" -o "${DEST}"

${SUDO} chmod +x "${DEST}"

echo
echo "🥳 FrankenPHP downloaded successfully to ${italic}${DEST}${normal}"
echo "🔧 Move the binary to ${italic}/usr/local/bin/${normal} or another directory in your ${italic}PATH${normal} to use it globally:"
echo " ${bold}sudo mv ${DEST} /usr/local/bin/${normal}"
echo " ${bold}sudo mv ${DEST} /usr/local/bin/${normal}"
echo
echo "⭐ If you like FrankenPHP, please give it a star on GitHub: ${italic}https://github.com/php/frankenphp${normal}"
Loading
Loading