Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add one line install script and instructions to README #594

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
74 changes: 74 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/sh

withinboredom marked this conversation as resolved.
Show resolved Hide resolved
set -e

if [ -z "$BIN_DIR" ]; then
BIN_DIR=$(pwd)
fi

THE_ARCH_BIN=""
THIS_PROJECT_OWNER="dunglas"
DEST=$BIN_DIR/frankenphp
Copy link
Owner

Choose a reason for hiding this comment

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

Why not install directly the binary in /usr/local/bin/? This will simplify the one-liner provided in docs.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think that change makes an assumption that there is a /usr/local/bin to install to or that the user has permissions to do so. I, personally, would be wary of running a random curl'd script with root permissions just to install something.

I think you can probably make the docs more readable by suggesting BIN_DIR:

curl -sLK https://raw.githubusercontent.com/dunglas/frankenphp/main/install.sh | BIN_DIR=/usr/local/bin sh

and modify the script prompt for sudo if it fails to copy.


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"