Next: , Previous: Working With Web Applications, Up: Command Line Use


5.2 Working With Console Applications

Command Line Interpreter

You can execute a PHP script immediately by running it through the Roadsend PHP interpreter:

     pcc -f myscript.php

The interpreter will use include and library paths from pcc.conf.

In Unix, you can create stand alone PHP shell scripts:

     
     $ cat script.php
     #!/opt/roadsend/pcc/bin/pcc -f
     <?
     
     echo "this is an example of an interpreted shell script\n";
     
     ?>
     $ ./script.php
     this is an example of an interpreted shell script
     $

Compiling

Roadsend PHP can compile a single source file (script), or several source files, into a stand alone application.

     
       <?php
     
         for ($i = 0; $i < 10; $i++) {
             $text[] = "My First Compiled PHP Program: $i\n";
         }
     
         foreach ($text as $op) {
             echo $op;
         }
     
       ?>
     

This program can be compiled with the following command:

     
     $ pcc -v first.php
     Compiling standalone target:
       output-path: first
       source-files: (first.php)
       libraries: ()
     
     compiling...
     creating console binary: first (dynamically linked)
     

By default, this will generate an executable named "first". Running the executable produces the following output:

     
         $ ./first
     My First Compiled PHP Program: 0
     My First Compiled PHP Program: 1
     My First Compiled PHP Program: 2
     My First Compiled PHP Program: 3
     My First Compiled PHP Program: 4
     My First Compiled PHP Program: 5
     My First Compiled PHP Program: 6
     My First Compiled PHP Program: 7
     My First Compiled PHP Program: 8
     My First Compiled PHP Program: 9
     

Deploying

For instructions on deploying with the Roadsend Studio IDE on Windows, see Deploying Your Project

On Unix, you may either link statically or include the necessary runtime libraries.

The appropriate Roadsend runtime libraries can be found in the runtime package, freely available on the roadsend.com website.