I am working on a script that requires ImageMagick and I need to check for it as well as enable it if it isn't enabled. I understand that I can enable extension=imagick.so
in my php.ini file. However, not everyone using the script will have access to that option. So I need to check on the fly and enable as I said earlier. I know that the PHP dl() method is deprecated, and I have tried several other things in an attempt to output the enabled extensions and have failed. Is there a method possible to enable the ImageMagick module from within a PHP script/file?
Here was my last attempt:
<?php
echo "<pre>";
print_r(get_loaded_extensions());
echo "</pre>";
if (!extension_loaded('imagick')) {
echo "<br><br><hr><br>";
echo "ADDING ImageMagick:<br><br>";
ini_set("extension", 'imagick.so');
echo "<pre>";
print_r(get_loaded_extensions());
echo "<pre>";
}
}
* UPDATE *
I just tried to create a php.ini fileand save it to a location in the 'system' folder but that too seems to have failed. ;)
<?php
echo "<pre>";
print_r(get_loaded_extensions());
echo "</pre>";
// Example loading an extension based on OS
if (!extension_loaded('imagick')) {
echo "<br><br><hr><br>";
echo "ADDING ImageMagick:<br><br>";
$content = "extension=imagick.so";
$fp = fopen("/my-root-path-behind-public-here/php.ini","wb");
fwrite($fp,$content);
fclose($fp);
echo "<pre>";
print_r(get_loaded_extensions());
echo "<pre>";
}