PHP Development

Understanding PHP Extensions and How to Check Them

Learn what PHP extensions do, how to inspect enabled modules, and how to resolve missing-extension issues across environments.

What is a PHP extension?

Extensions add capabilities to PHP. Some provide database drivers, while others support image processing, internationalization, encryption, compression, or network requests.

List loaded extensions

From the command line:

php -m

To inspect a particular extension:

php --ri curl
php --ri pdo_mysql

You can also check from PHP code:

<?php
var_dump(extension_loaded('curl'));
var_dump(extension_loaded('pdo_mysql'));

CLI and web PHP may differ

A frequent source of confusion is that the command-line PHP binary and the PHP version used by the web server may have different versions, configuration files, or loaded modules.

Inspect the CLI configuration with:

php --ini
php -v

For web requests, use a temporary diagnostic script that reports PHP_VERSION and selected extension status. Protect it from public access and remove it immediately after testing. Avoid leaving a full phpinfo() page online.

Fix missing extensions

Use the hosting control panel or server package manager supported by your environment. After enabling an extension, verify it in both CLI and web contexts and restart the relevant service if required.

Document required extensions in your project setup instructions so new environments can be prepared consistently.