You could make a HTTP request to a PHP file that tries to include the file, and outputs "OK" at the end.
Check_include.php:
$filename = $_GET["plugin"];
$filename = sanitize_filename($filename); // Here you make sure only plugins can be loaded
include ($filename);
echo "OK";
then, in your admin panel or whatever, call
file_get_contents("http://mydomain/check_include.php?plugin=my_new_plugin");
and see whether the result contains the word "OK". If the result is okay, there was no fatal error, and you can activate the plugin; otherwise, you can even output the error message that got output when trying to include it.
WordPress uses a variation of this involving an IFRAME to check new plugins.
Note: Making a HTTP request is expensive. You should under no circumstances do this every time the plugin is included, but only once on installation. Use a flag of some sort (e.g. a underscore _
in front of the plugin name) to enable / disable plugins.