Suppose you are facing library issues, you get the library functions error then first you need to check the module is loaded or not. It is very easy to confirm the library is installed or not. In this article, I will let you know how can you check the PHP extensions are loaded or not.
How to check extensions loaded or not by PHP?
Using Command Line:
If you using a command line then you can use the below command to get all module lists.
php -m
If you want details information, you can use php -i to get phpinfo(); response.
php -i
Run below command to check all loaded extensions by PHP:
php -r "print_r(get_loaded_extensions());"
Check specific extensions whether extension is installed or not.
php -r "print_r(get_loaded_extensions('gd'));"
If you want to uninstall all modules and install all again. Use below command with PHP version.
dpkg -l | grep php5
To view all PHP command-line options, run below command.
php -h
Using PHP code:
You can show all PHP information by using the below code. You can find the extension name. Do ctrl+f and search the extension name.
<?php
phpinfo();
?>
To get all loaded extensions, please use below code.
<?php
echo "<pre>";
print_r(get_loaded_extensions());
echo "<pre/>";
?>
You can also check any specific extensions whether the extension is installed or not. In the below code, I checked GD Library is installed or not. Thus you can check for other extensions also.
<?php
if (extension_loaded('gd') && function_exists('gd_info')) {
echo "GD library is installed.";
}
else {
echo "GD library is NOT installed.";
}
?>
Thanks for reading, feel free to reach out to me for any comments and suggestions. I hope you found the article helpful and you were able to fix the PHP library issues..