How to run Php Export Script

I am trying to run a php export script in Bootstrap Studio. Running the script in the console (Windows 10) like this is ok:

c:\xampp\php\php.exe c:\xampp\htdocs\Nuurdwind\export-test.php

or

php.exe c:\xampp\htdocs\Nuurdwind\export-test.php

(i.e. the PATH has been extended by "c:\xampp\php\" ) or simply

c:\xampp\htdocs\Nuurdwind\export-test.php

(the extension .php has been associated with c:\xampp\php\php.exe)

But when it comes to Bootstrap Studio, the script is not executed and the error.log file contains the follwing message:

Couldn't execute script C:\xampp\htdocs\Nuurdwind\export-test.php

The export settings in Bootstrap Studio are as follows:

Export destination: C:\xampp\htdocs\Nuurdwind

Advanced: C:\xampp\htdocs\Nuurdwind\export-test.php

The export script itself is very simple, it's just for testing:

<?php
  #!c:\xampp\php\    // not sure if this line is of any importance, it seems to make no difference
  $datei = fopen("c:\xampp\htdocs\Nuurdwind\index.html","w");
  echo fwrite($datei, "Hallo Welt",100);
  fclose($datei);
?>  

Can anybody help?

Henry

Thanks for starting this thread! Bootstrap Studio executes export scripts in a similar way to how CMD.exe runs them. So you need to make your script run when you type its path in a command prompt and hit enter. For Linux and Mac it's easy - add the #! line at the top and make the script executable. I am not exactly sure what the correct steps for Windows are, but I think it will involve making a batch file that executes the PHP interpreter somehow.

On the command line I can run for instance

 c:\xampp\htdocs\Nuurdwind\export.bat

or

C:\xampp\php\php.exe c:\xampp\htdocs\Nuurdwind\export.php

That works fine. But when I put these lines to the export settings, the error.log file has a message like "Script C:\xampp\php\php.exe c:\xampp\htdocs\Nuurdwind\export.php couldn't be run" Why not? There is no further explanation.

The second command isn't really a script (single executable entity), but a command + argument, so it isn't supported.

The first one with the bat file should work though. What error does it produce in the error.log?

The message is in German which makes me think it is a system message, not a message produced by BSS.

This is what it says:

The command "c:\" is either written in the wrong way or could not be found.

The system cannot find the path.

Solution:

  1. A Windows batch file accepts c:\\ and c:\ to specify a rootdirectory while PHP definitely wants c:\\

  2. Set the destination directory in the script file.

Here comes a simple example that calls a php file from within a batch file. As a result index.html is overwritten with the current directory which is the Bootstrap Studio installation directory. This IS NOT the preset Destination Directory(!). So it makes sense to specify the working directory in the script file .

exp1.bat

c:
REM Specify destination directory, this path is ok:
REM cd c:\\xampp\htdocs\Nuurdwind 

REM this path is ok too:
REM cd c:\xampp\htdocs\Nuurdwind

REM If the target directory is not specified as shown above
REM the full path for the script file must be provided:
C:\\xampp\php\php.exe c:\\xampp\htdocs\Nuurdwind\exp1.php

exp1.php <?php $actdir = getcwd(); // get actual directory

// this path is ok
$txt="c:\\xampp\htdocs\Nuurdwind\index.html";

// this path is NOT ACCEPTED BY PHP
//$txt="c:\xampp\htdocs\Nuurdwind\index.html";


$datei=fopen($txt, "w");

echo fwrite($datei,$actdir,100);

?>

However, I did not find a solution for running a php-file directly, i.e. without the batch file, even though the php-extension has been associated with php.exe.