php runtime and server environment

Configure Options

Configure options are the choices used when PHP itself is compiled. They decide which SAPIs, paths, libraries, and built-in features are included in that PHP binary.

Most developers install PHP from an operating-system package, Docker image, Homebrew, a hosting provider, or a managed platform. You may never compile PHP manually at work, but configure options still explain why two machines running "PHP 8.3" can behave differently.

Build-time versus runtime

Runtime settings are changed in php.ini, pool config, environment variables, or application config. Build-time options are chosen before PHP is installed.

Examples of runtime settings:

memory_limit = 256M
upload_max_filesize = 10M
opcache.enable = 1

Examples of build-time configure options:

--prefix=/usr
--with-config-file-path=/etc/php/8.3/fpm
--enable-fpm
--with-openssl
--with-curl
--with-zlib

If PHP was built without support for a feature, changing php.ini may not be enough. You may need a different package, an extension package, or a different image.

Inspecting configure options

From the command line, php -i includes the configure command. In PHP code, phpinfo() displays it too, but phpinfo() should not be public in production.

PHP example
<?php

declare(strict_types=1);

ob_start();
phpinfo(INFO_GENERAL);
$info = ob_get_clean();

echo str_contains($info, 'Configure Command') ? 'configure command available' : 'not found';
echo PHP_EOL;

// Prints:
// configure command available

For routine checks, prefer command-line inspection or a protected diagnostic environment. Public phpinfo() pages leak paths, modules, environment details, and configuration values.

Extensions can be built in or loaded

Some features are compiled into PHP. Others are shared extensions loaded through .ini files.

PHP example
<?php

declare(strict_types=1);

$extensions = ['curl', 'openssl', 'pdo', 'mbstring', 'intl'];

foreach ($extensions as $extension) {
    echo $extension . ': ' . (extension_loaded($extension) ? 'loaded' : 'missing') . PHP_EOL;
}

// Prints:
// curl: loaded
// openssl: loaded
// pdo: loaded
// mbstring: loaded
// intl: missing

If intl is missing, the fix is often installing a package such as php-intl, enabling it for the correct SAPI, and reloading PHP-FPM. It is not usually solved by changing application code.

Different SAPIs can differ

CLI PHP and PHP-FPM may use different binaries or different configuration directories. That means a feature can appear in php -m but still be missing in the web application, or the other way around.

PHP example
<?php

declare(strict_types=1);

echo 'SAPI: ' . PHP_SAPI . PHP_EOL;
echo 'PHP binary version: ' . PHP_VERSION . PHP_EOL;
echo 'Loaded ini: ' . (php_ini_loaded_file() ?: 'none') . PHP_EOL;

// Prints:
// SAPI: cli
// PHP binary version: 8.3.6
// Loaded ini: /etc/php/8.3/cli/php.ini

When a bug happens through the browser, inspect the web SAPI. A CLI check is useful, but it does not prove PHP-FPM has the same extension set.

When configure options matter in jobs

Configure options show up when:

  • a Docker image lacks an extension needed by Composer
  • production has intl, zip, gd, imagick, or pdo_mysql missing
  • local PHP and CI PHP have different extension support
  • a hosting provider exposes limited PHP builds
  • a team chooses between distro packages and custom PHP builds
  • a security review asks which libraries PHP was compiled with

Junior developers are not usually expected to design a PHP build from source. They are expected to read the environment, identify missing capabilities, and explain whether the fix belongs in code, package installation, Dockerfile, or server configuration.

What you should be able to do

After this lesson, you should be able to distinguish build-time configure options from php.ini settings, inspect loaded extensions, recognise SAPI differences, and avoid assuming that every PHP 8.3 installation has the same capabilities.

Practice

Task: Check PHP Capabilities

Create a PHP diagnostic script that checks whether the current PHP runtime has the capabilities a project needs.

Requirements

  • Print the current SAPI and loaded php.ini path.
  • Check whether curl, openssl, pdo, mbstring, and intl are loaded.
  • Print a clear loaded or missing result for each extension.
  • Add a short note explaining why a CLI result may not prove the PHP-FPM runtime is ready.
  • Do not expose the full output of phpinfo() publicly.

Check your work

The output should help decide whether the fix is likely package installation, extension enabling, Docker image changes, or application code.

Show solution
PHP example
<?php

declare(strict_types=1);

echo 'SAPI: ' . PHP_SAPI . PHP_EOL;
echo 'PHP version: ' . PHP_VERSION . PHP_EOL;
echo 'Loaded ini: ' . (php_ini_loaded_file() ?: 'none') . PHP_EOL;

$requiredExtensions = ['curl', 'openssl', 'pdo', 'mbstring', 'intl'];

foreach ($requiredExtensions as $extension) {
    echo $extension . ': ' . (extension_loaded($extension) ? 'loaded' : 'missing') . PHP_EOL;
}

// Prints:
// SAPI: cli
// PHP version: 8.3.6
// Loaded ini: /etc/php/8.3/cli/php.ini
// curl: loaded
// openssl: loaded
// pdo: loaded
// mbstring: loaded
// intl: missing

If this script is run from CLI, it proves the CLI runtime only. A browser problem must be checked through PHP-FPM or the web SAPI because it may load a different php.ini file and a different extension set. Missing extensions are usually fixed by installing or enabling packages, changing the Docker image, or selecting the correct PHP build, not by changing business logic.