Extensible and debuggable PHP

For anyone else working on PHP applications under Habitat, I’ve figured some things out that might be helpful under an enhanced php plan:

Debugging

The emergence/php package comes with xdebug compiled and available as a shared extension you can enable:

mkdir -p /hab/user/php/config
echo '
[extensions.xdebug]
enabled=true
[extensions.xdebug.config]
remote_port=5089
' > /hab/user/php/config/user.toml

Extensions

Here’s an example of a separately installable extension:

The install hook symlinks the .so files into "/hab/svc/php/var/extensions-{{ pkg.env.PHP_API_VERSION }}/" (the emergence/php package publishes PHP_API_VERSION to runtime env) and then an extension can be enabled with:

mkdir -p /hab/user/php/config
echo '
[extensions.sqlsrv]
enabled=true

[extensions.pdo_sqlsrv]
enabled=true
' > /hab/user/php/config/user.toml