Collection of PHP pre-execution script helpers. These helpers leverage the PHP auto_prepend_file configuration directive to modify the runtime environment before the main application script is executed. They are primarily used by docker-php-apache and docker-apache-mvh containers. While currently specific, we aim to make them more generic in the future and welcome contributions.
Important
Maintained by Panubo — Cloud Native & SRE Consultants in Sydney. Work with us →
Adjusts $_SERVER variables to correctly reflect the client's IP and protocol when the application is behind a reverse proxy.
- Sets
$_SERVER['REMOTE_ADDR']fromHTTP_X_REAL_IP. - Sets
$_SERVER['HTTPS'] = 'on',$_SERVER['REQUEST_SCHEME'] = 'https'and$_SERVER['protossl'] = 's'ifHTTP_X_FORWARDED_PROTOishttps.
A focused helper for SSL termination. If you only need to handle the SSL part and not the remote address, use this helper.
- Sets
$_SERVER['HTTPS'] = 'on',$_SERVER['REQUEST_SCHEME'] = 'https'and$_SERVER['protossl'] = 's'ifHTTP_X_FORWARDED_PROTOishttps.
Configures WordPress using environment variables. This is useful for containerized WordPress deployments. It can set common configuration values like database credentials and security keys automatically.
The following environment variables can be used:
DB_HOSTDB_NAMEDB_USERDB_PASSWORDDB_CHARSETWP_DEBUGWP_HOMEWP_SITEURLAUTH_KEYSECURE_AUTH_KEYLOGGED_IN_KEYNONCE_KEYAUTH_SALTSECURE_AUTH_SALTLOGGED_IN_SALTNONCE_SALT
Allows you to use multiple auto_prepend_file files. It reads a comma-separated list of file paths from the MULTI_PREPEND environment variable and includes them.
You can enable the helpers by setting the auto_prepend_file directive in your php.ini or webserver configuration.
Set the following php.ini variable to enable the SSL helper:
auto_prepend_file=SSLHelper_prepend.php
Or for Apache configuration:
<Directory /srv/www/>
AllowOverride All
Require all granted
<If "-T env('BEHIND_PROXY')">
php_value auto_prepend_file "ProxyHelper_prepend.php"
</If>
</Directory>To use multiple helpers, use Multi_prepend.php and set the MULTI_PREPEND environment variable with a comma-separated list of the prepend files you want to include.
Example:
Set auto_prepend_file to Multi_prepend.php:
auto_prepend_file=Multi_prepend.php
Set the MULTI_PREPEND environment variable:
MULTI_PREPEND=ProxyHelper_prepend.php,WordPressHelper_prepend.php
This will load both ProxyHelper and WordPressHelper.
To install in a Docker image:
# Install PHP Extras
RUN set -x \
&& PHPEXTRAS_VERSION=0.2.0 \
&& PHPEXTRAS_SHA256=1dc751f28ceb799d82c069807df681a9debba2e66e7f37c95ed5e80776f341d1 \
&& if ! command -v wget > /dev/null; then \
fetchDeps="${fetchDeps} wget"; \
fi \
&& apt-get update \
&& apt-get install -y --no-install-recommends ${fetchDeps} \
&& cd /tmp \
&& wget -nv https://github.com/panubo/php-extras/releases/download/v${PHPEXTRAS_VERSION}/php-extras.tar.gz \
&& echo "${PHPEXTRAS_SHA256} php-extras.tar.gz" > /tmp/SHA256SUM \
&& ( cd /tmp; sha256sum -c SHA256SUM || ( echo "Expected $(sha256sum php-extras.tar.gz)"; exit 1; )) \
&& mkdir -p /usr/share/php/ \
&& tar --no-same-owner -C /usr/share/php/ -zxf php-extras.tar.gz \
&& rm -rf /tmp/* \
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false ${fetchDeps} \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
;Important
This project is maintained by Panubo, a technology consultancy based in Sydney, Australia. We build reliable, scalable systems and help teams master the cloud-native ecosystem.
We are available for hire to help with:
- SRE & Operations: Improving system reliability and incident response.
- Platform Engineering: Building internal developer platforms that scale.
- Kubernetes: Cluster design, security auditing, and migrations.
- DevOps: Streamlining CI/CD pipelines and developer experience.
- See our other services
Need a hand with your infrastructure? Let’s have a chat or email us at team@panubo.com.