dark_mode EN

WPhpRunner

  • Inherits from: None

    File: zPhpRunner.prg

This class allows you to execute any PHP script locally on the web server from your CGI. This class allows you to greatly expand the capabilities of xaWeb. The script is executed in CLI mode, not CGI mode, so it is much faster than if the request were made via HTTP. The web server must support PHP, and the configuration will vary depending on the environment where the CGI is executed.

For Windows environments, we recommend installing XAMPP, which offers an Apache2 server along with PHP. The installation is done by default in the 'c:\xampp' folder, and the PHP script executor (php.exe) is located in the 'c:\xampp\php' folder.

For Linux environments, PHP is built into almost all system management packages such as cPanel or Plesk. If not, we recommend consulting the PHP documentation for the operating system you are using.

Example:
WITH OBJECT oPhp := WPhpRunner():New()
  :cPhpModule := "Neptuno.php"
  :cphpRunner := "c:\xampp\php\php.exe"
  HB_HSet( :hPost, "data", "ping" )
  HB_HSet( :hGet, "command", "PING" )
  HB_HSet( :hGet, "activate", 123445678 )
  WITH OBJECT WDiv():New( Self )
    IF !oPhp:Run()
      ECHO "Error"
    ELSE
      ECHO oPhp:cResult 
    ENDIF
  END WITH
END WITH
Important Note: Running PHP scripts in a Linux environment is very fast. Unfortunately, it's not as fast in Windows, due to the slowness of that operating system when running external processes.