mirror of
https://github.com/dunglas/frankenphp
synced 2024-10-16 09:08:22 +00:00
caddy | ||
testdata | ||
.gitignore | ||
CONTRIBUTING.md | ||
Dockerfile | ||
frankenphp_test.go | ||
frankenphp.c | ||
frankenphp.go | ||
frankenphp.h | ||
go.mod | ||
go.sum | ||
README.md |
Caddy PHP
Install
Docker
The easiest way to get started is to use our Docker image:
docker build -t frankenphp .
Compile fron Sources
Install PHP
Most distributions doesn't provide packages containing ZTS builds of PHP. Because the Go HTTP server uses goroutines, a ZTS build is needed.
Start by downloading the latest version of PHP, then follow the instructions according to your operating system.
Linux
./configure --enable-embed --enable-zts
make
make install
Mac
brew install libiconv
./configure \
--enable-zts \
--enable-embed=static \
--with-iconv=/opt/homebrew/opt/libiconv/ \
--without-pcre-jit
make
make install
Then, you also need to build a Mac-compatible PHP shared library. As the standard PHP distribution doesn't provide one, you need to do a few extra steps:
Start by adding those lines at the end of the Makefile
:
libs/libphp.dylib: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS)
$(LIBTOOL) --mode=link $(CC) -dynamiclib $(LIBPHP_CFLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) -rpath $(phptempdir) $(EXTRA_LDFLAGS) $(LDFLAGS) $(PHP_RPATHS) $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@
-@$(LIBTOOL) --silent --mode=install cp $@ $(phptempdir)/$@ >/dev/null 2>&1
Then run:
make libs/libphp.dylib
sudo cp libs/libphp.dylib /usr/local/lib/
Compile the Go App
go get -d -v ./...
go build -v