2

I made a PHP library that uses proc_open and relies on external application to process data.

Now, I need to make a "check" file that will analyze the server and return if my library can be used on it.

I figured these steps are enough:

  • Check if proc_open is allowed
  • Check if external application is installed

How do I check if proc_open is allowed? Also, I guess proc_open works on windows-based servers too (just using windows command prompt instead of terminal)?

1 Answers1

2

if( function_exists("proc_open")) would be a good start. Then use a try..catch block to attempt to call a simple proc_open test. If the test passes, then proc_open is allowed.

As for the external application, if it defines any functions you can use function_exists to check and see if it is installed and working.

Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592
  • Oh, I thought function_exist would return true always since proc_open is core PHP function. Will it return false if server admin disabled it? About using `function_exists` for external app check, how do you mean I can use it through `proc_open`? I wanted to handle this by using `type MY_EXTERNAL_APP` on linux (which allows me to check if external app is installed) and some similar function on windows, I would google it, there must be one. –  Jan 28 '13 at 01:02
  • @user2742648 not always actually. From server to server, you may encounter a situation where this function simply does not exist. – Ivan Stasiuk Jan 01 '18 at 14:50