Multi-Method Extension Verification for Debugging

πŸ“– 1 minute read

Multi-Method Extension Verification for Debugging

When debugging missing PHP extension errors in Docker, use multiple verification methods to confirm what’s actually installed vs what the application can see.

Method 1: List All Loaded Modules

docker exec my-app php -m

Method 2: Runtime Check via PHP Code

docker exec my-app php -r "echo extension_loaded('redis') ? 'YES' : 'NO';"

Method 3: Check php.ini Configuration

docker exec my-app php --ini
# Shows which ini files are loaded

Method 4: Test Actual Function Availability

docker exec my-app php -r "var_dump(function_exists('redis_connect'));"

Why Multiple Methods?

  • php -m shows modules PHP knows about
  • extension_loaded() checks if the extension is active in the current context
  • Function checks verify the extension’s API is actually usable

In debugging sessions, cross-reference all three to isolate whether the issue is installation, configuration, or application-level detection.

Pro tip: If php -m shows the extension but extension_loaded() returns false, check your php.ini configuration and verify the extension is enabled for the SAPI you’re using (CLI vs FPM).

Daryle De Silva

VP of Technology

11+ years building and scaling web applications. Writing about what I learn in the trenches.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *