phprequirementspcntl

How to check PCNTL module exists


I write simple requirements checking script. It checks all required PHP modules installed. I need to check if pcntl is installed. But this module is accessible only in cgi environment and invisible for web queries. extension_loaded('pcntl') and function_exists('pcntl_fork') both return false. How can I perform this check?


Solution

  • Create a file called cli_supports.php

      <?php
      $supports = array();
      if (function_exists("pcntl_fork")) $supports[] = "pcntl";
      echo implode(",", $supports);
      ?>
    

    Then from your feature detection scripts do.

      $cli_features = explode(",", shell_exec("/usr/local/bin/php ".escapeshellarg(_DIR_."/cli_supports.php")));