Why my PHP EXTENSION is not loaded by Windows Azure Websites?

 

Windows Azure Websites provides customer a feature to enable custom PHP extensions. This allows customer add PHP Extensions based on application requirement. One common issues customer facing is sometimes the PHP/ZEND extensions doesn’t load as expected after they configured it. During this article, I will show you how to troubleshooting this type of problem.

1. What type of extension do you want to configure?

 

There are two types of extensions: PHP extensions and Zend extensions. The difference between these two extension types is mainly in hooks they register into the Engine. So, the first thing you need to do is contact the vendor or check the documentation to identify the extension type (Zend or PHP).

 

For a PHP extension, we need add PHP_EXTENSIONS entry under the app settings section. For a Zend extension, we need to add PHP_ZENDEXTENSIONS entry under the app settings section. Here is a screenshot for your reference.

 

In php_errors.log, you should able to find errors like below if you configured wrong type of extension.

 

PHP Warning: Xdebug MUST be loaded as a Zend extension in Unknown on line 0

PHP Warning: PHP Startup: Unable to load dynamic library 'C:\DWASFiles\Sites\php-mysql\VirtualDirectory0\site\wwwroot\bin\ioncube_loader_win_5.4.dll' - The specified procedure could not be found.

 

2. Configure the right version of extension

 

Some extensions may have requirement for PHP versions. Make sure to also check the provider's documentation for possible compatibility issues, PHP version compatibility and any other additional configurations that may be required. To know the current version of PHP running on Windows Azure Websites, create a PHP file like this.

<?php

phpinfo();

?>

 

3. Mismatched Architecture

You need to pay attention to X86/X64 as well. If you upload a X64 version of extension while PHP itself is X86 version. You may see follow message in php_errors.log.

 

PHP Warning: PHP Startup: Unable to load dynamic library 'C:\DWASFiles\Sites\php-mysql\VirtualDirectory0\site\wwwroot\bin/php_intl.dll' - %1 is not a valid Win32 application.

4. Dependencies

 

Some PHP/ZEND extensions may rely on other binaries which is not available on Windows Azure Websites hosting machines. In this scenario, you may see follow message in the php_errors.log.

 

PHP Warning: PHP Startup: Unable to load dynamic library 'C:\DWASFiles\Sites\php-mysql\VirtualDirectory0\site\wwwroot\bin\php_intl.dll' - The specified module could not be found.

 

To find out the binaries used by the extension, you can try Depends utility. The tool is available here.

https://dependencywalker.com/

 

Here is a screenshot for your reference. To make your extension work, you may need upload the yellow highlighted binaries with your extension.

 

 

See you next time,

Wei