PL/php Installation =================== PL/php builds with PostgreSQL's standard extension build infrastructure (PGXS) and links against the PHP "embed" SAPI. 1. Prerequisites ---------------- * PostgreSQL 11 or newer (tested on 11-18), including the server development files that provide pg_config (Debian/Ubuntu: postgresql-server-dev-NN; RPM: postgresqlNN-devel). * PHP 8.x built with the embed SAPI and with thread safety (ZTS) DISABLED, plus its development files (php-config). On Debian/Ubuntu: sudo apt-get install php8.3-dev libphp8.3-embed You can confirm the build is suitable with: php-config --php-sapis # must list "embed" php -i | grep 'Thread Safety' # must say "disabled" If your distribution does not package the embed SAPI, build PHP from source with: ./configure --enable-embed ... (and without --enable-zts). * A C compiler and GNU make. 2. Build and install --------------------- From PGXN, which downloads, builds, and installs the current release: pgxn install plphp From a source checkout: make sudo make install The Makefile locates PostgreSQL via pg_config and PHP via php-config, both taken from PATH. Override them if needed: make PG_CONFIG=/usr/lib/postgresql/18/bin/pg_config PHP_CONFIG=/usr/bin/php-config sudo make PG_CONFIG=/usr/lib/postgresql/18/bin/pg_config install Note: if several libphpX.Y-embed versions are installed side by side, some packagings (e.g. deb.sury.org) give them all the same SONAME (libphp.so), so the backend loads whatever /usr/lib/libphp.so points at -- regardless of the version linked at build time. Keep a single embed package installed, or point that symlink at the intended version. This installs the shared library plphp.so plus the extension control and SQL files into the directories reported by pg_config. The optional transforms (jsonb_plphp, hstore_plphp, bytea_plphp; see doc/plphp.md) build the same way, each in its own directory: make -C jsonb_plphp PG_CONFIG=... PHP_CONFIG=... sudo make -C jsonb_plphp PG_CONFIG=... install 3. Enable the language in a database ------------------------------------ CREATE EXTENSION plphp; PL/php is an untrusted language, so the extension is superuser-only to install and only superusers can create PL/php functions. See the SECURITY NOTE in README for why. 4. Run the regression tests (optional) -------------------------------------- Against a running server whose pg_config is on PATH (or passed via PG_CONFIG): make installcheck The suite installs the extension and exercises scalar functions, arrays, composite/record types, triggers, set-returning functions, SPI, argument handling (IN/OUT/INOUT/TABLE, named parameters) and the validator.