I am developing an install script for my application, how would I go about checking if MongoDB is installed or not with a PHP driver on a server??
Many thanks
The easiest way of checking it would be to run:
echo extension_loaded("mongo") ? "loaded\n" : "not loaded\n";
See also: http://php.net/manual/en/function.extension-loaded.php
get_loaded_extensions — Returns an array with the names of all modules compiled and loaded.
print_r(get_loaded_extensions());
You can check by using class_exists
if (class_exists('Mongo')) {
// MongoDB is installed
}
else {
// MongoDB is not installed
}
I am developing an install script for my application, how would I go about checking if MongoDB is installed or not with a PHP driver on a server??
Many thanks
The easiest way of checking it would be to run:
echo extension_loaded("mongo") ? "loaded\n" : "not loaded\n";
See also: http://php.net/manual/en/function.extension-loaded.php
get_loaded_extensions — Returns an array with the names of all modules compiled and loaded.
print_r(get_loaded_extensions());
You can check by using class_exists
if (class_exists('Mongo')) {
// MongoDB is installed
}
else {
// MongoDB is not installed
}
0 commentaires:
Enregistrer un commentaire