How do I see the extensions loaded by PHP?

How do I see the extensions loaded by PHP?

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

How do I see the extensions loaded by PHP?

If you are debugging a PHP application and suspect that an extension isn't behaving as expected, your first instinct might be to dump the entire configuration or rely on phpinfo(). However, sifting through hundreds of lines of output to find a specific module is inefficient and prone to error. The information you need is present, but it requires knowing exactly where to look within the data structures generated by the PHP runtime.

The most comprehensive method to view loaded extensions is via the phpinfo() function. While your intuition about the "Additional Modules" section is partially correct, that label is often a misnomer in modern PHP versions. In older PHP 5 releases, this section was distinct and clearly labeled. In PHP 7, 8, and beyond, the output structure has evolved. The relevant data is now typically found under the "Loaded Extensions" heading.

When you execute phpinfo(), look specifically for the block titled Loaded Extensions. This section lists every shared object (.so file) that the PHP interpreter successfully linked against during startup. It provides the extension name, its version, and often the path to the module file. If an extension is missing from this list despite being present in your extension directives, it usually indicates a failure during the initialization phase—perhaps due to a missing dependency, a conflicting library, or a syntax error in the extension's configuration block.

However, relying solely on phpinfo() has limitations, particularly when running PHP as a command-line tool (CLI) versus an embedded SAPI like Apache or Nginx via FastCGI. The output can differ based on how the server was compiled and which modules were built statically versus dynamically. To bypass these SAPI-specific variances, you should use the php --ini command combined with checking the php.ini file directly.

php -i | grep enabled_only

This specific flag in the CLI output provides a cleaner list of only the extensions that are currently active, filtering out those that are compiled but not loaded or disabled via configuration. It is often more reliable for scripting checks than parsing the verbose HTML/Text output of phpinfo().

For developers working with Laravel or other modern frameworks, understanding this distinction is crucial. Frameworks often rely on specific extensions like pdo_mysql, mbstring, or openssl to function correctly. If a feature silently fails because an extension is missing, you need to verify the runtime state rather than just checking your configuration files.

A common pitfall occurs when mixing php.ini settings with environment variables. In Docker environments or specific hosting setups, PHP_EXTENSIONS or LD_LIBRARY_PATH might override default behavior, causing extensions to appear in the config file but not load at runtime. Always verify the actual loaded state using the CLI commands mentioned above before assuming a configuration error.

If you are managing a large fleet of servers or need to automate checks, relying on manual inspection of phpinfo() is impractical. You might consider writing a script that executes php -m and parses the output for specific keywords. While phpinfo() offers detailed metadata useful for troubleshooting complex dependency issues, php -m provides a concise list suitable for health checks.

Ultimately, the "Additional Modules" section you were looking for exists, but its exact location and content depend on your PHP version and build configuration. By targeting the "Loaded Extensions" header in phpinfo() or utilizing the php -m command, you can accurately diagnose why an extension is missing from your application's behavior without getting lost in unnecessary details.

Our network