diff --git a/README.md b/README.md index 696e6ee3a..c14c9db59 100644 --- a/README.md +++ b/README.md @@ -34,18 +34,26 @@ Go to `https://localhost`, and enjoy! ### Standalone Binary If you prefer not to use Docker, we provide standalone FrankenPHP binaries for Linux and macOS -containing [PHP 8.3](https://www.php.net/releases/8.3/en.php) and most popular PHP extensions: [Download FrankenPHP](https://github.com/dunglas/frankenphp/releases) +containing [PHP 8.3](https://www.php.net/releases/8.3/en.php) and most popular PHP extensions. + +[Download FrankenPHP](https://github.com/dunglas/frankenphp/releases) or copy this line into your +terminal to automatically install the version appropriate for your platform: + +```console +curl -sLK https://raw.githubusercontent.com/dunglas/frankenphp/main/install.sh | sh +mv frankenphp /usr/local/bin/ +``` To serve the content of the current directory, run: ```console -./frankenphp php-server +frankenphp php-server ``` You can also run command-line scripts with: ```console -./frankenphp php-cli /path/to/your/script.php +frankenphp php-cli /path/to/your/script.php ``` ## Docs diff --git a/install.sh b/install.sh new file mode 100644 index 000000000..8a8b8feb0 --- /dev/null +++ b/install.sh @@ -0,0 +1,74 @@ +#!/bin/sh + +set -e + +if [ -z "$BIN_DIR" ]; then + BIN_DIR=$(pwd) +fi + +THE_ARCH_BIN="" +THIS_PROJECT_OWNER="dunglas" +DEST=$BIN_DIR/frankenphp + +OS=$(uname -s) +ARCH=$(uname -m) + +case $OS in + Linux*) + case $ARCH in + arm64) + THE_ARCH_BIN="" + ;; + aarch64) + THE_ARCH_BIN="$THIS_PROJECT_NAME-linux-aarch64" + ;; + armv6l) + THE_ARCH_BIN="" + ;; + armv7l) + THE_ARCH_BIN="" + ;; + *) + THE_ARCH_BIN="$THIS_PROJECT_NAME-linux-x86_64" + ;; + esac + ;; + Darwin*) + case $ARCH in + arm64) + THE_ARCH_BIN="$THIS_PROJECT_NAME-mac-arm64" + ;; + *) + THE_ARCH_BIN="$THIS_PROJECT_NAME-mac-x86_64" + ;; + esac + ;; + Windows|MINGW64_NT*) + THE_ARCH_BIN="" + ;; +esac + +if [ -z "$THE_ARCH_BIN" ]; then + echo "This script is not supported on $OS and $ARCH" + exit 1 +fi + + +SUDO="" + +# 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 $DEST, enter your password to grant sudo powers" + SUDO="sudo" +fi + +$SUDO curl -L --progress-bar "https://github.com/$THIS_PROJECT_OWNER/$THIS_PROJECT_NAME/releases/latest/download/$THE_ARCH_BIN" -o "$DEST" + +$SUDO chmod +x "$DEST" + + +echo "Installed successfully to: $DEST" +