Symisc PH7 Engine
An Embeddable PHP5 Engine

Frequently Asked Questions.


  1. What is PH7

  2. How do I get started

  3. Where can I find the simplest C program that embed PH7.

  4. Where can I find online community support

  5. What is the PH7 license

  6. In which platforms PH7 run

  7. How can I copy arrays

  8. How can I create a foreign function and call it from my PHP code

  9. How can I create a foreign constant and expand its value from my PHP code

  10. How can I extract array entries values inside my foreign function

  1. How can I extract object attributes values inside my foreign function

  2. How can I return a array from my foreign function

  3. How can I configure my virtual machine with a HTTP request

  4. How can I perform an echo call in my foreign C function

  5. How can I throw an error in my foreign C function

  6. How can I stop program execution inside my foreign function

  7. Is PH7 thread-safe

  8. How can I return a multi-dimensional array in my foreign function

  9. How can I contribute to the PH7 development

  10. Where can I report bugs


  1. What is PH7

    PH7 is a in-process library that implements a highly-efficient embeddable bytecode compiler and a virtual machine for the PHP programming language. In other words, PH7 is a PHP engine which allow the host application to compile and execute PHP scripts in-process. PH7 implements most of the constructs introduced by the PHP 5.3 release and introduces very powerful extensions to the PHP language such as function overloading, full type hinting, 64-bit integer for all architectures, floating point comparison and many more. For the full list of extensions introduced by PH7, refer to the feature page.


  2. How do I get started

    PH7 is very easy to learn, even for new programmer. Here is some useful links to start with:

    PH7 In 5 Minutes Or Less gives a high-level overview on the how to embed the PH7 Engine in a host application.
    An Introduction To The PH7 C/C++ Interface gives an overview and roadmap to the C/C++ interface to PH7.
    Download some working examples from the
    download page.


  3. Where can I find the simplest C program that embed PH7.

    Download and Compile this C File. This program compile and execute the following PHP script.

    <?php
       echo 'Welcome guest'.PHP_EOL;
       echo 'Current system time is: '.date('Y-m-d H:i:s').PHP_EOL;
       echo 'and you are running '.php_uname();
    ?>

    That is, this simple script when running should display a greeting message, the current system time and the host operating system.


  4. Where can I find online community support

    Need some help, PH7 have a growing online community of users, visit the PH7 support page for additional information.


  5. What is the PH7 license

    PH7 is dual-licensed and is available free of charge for open-source projects under the term of the Symisc Public License (SPL) which is GPL compatible. See the licensing page for additional information.


  6. In which platforms PH7 run

    PH7 is written in ANSI C, compiles unmodified and should run in any platform including restricted embedded device with a C compiler. PH7 is extensively tested on Windows and UNIX systems especially Linux, FreeBSD, Oracle Solaris and Mac OS X. If you have successfully compiled PH7 in an exotic environment, please post a report on the PH7 forums or send an email to devel@symisc.net


  7. How can I copy arrays
    Unlike the zend engine which passes arrays by copy, PH7 pass arrays by reference exactly like PHP5 does with objects (class instances). That is, when assigning an already created instance of an array to a variable, the new variable
    will access the same instance as the array that was assigned. In other words arrays are shared between variables. This behavior is the same when passing arrays to a function. A copy of an array can be made using the array_copy() built-in function inside your PHP code to mimic the zend engine behavior. For a full discussion on this extension, refer to the feature page.


  8. How can I create a foreign function and call it from my PHP code

    Create a C function performing the desired computation then register it using the ph7_create_function() interface. After that the foreign function can be called from your PHP code.

    See this tutorial for additional information.


  9. How can I create a foreign constant and expand its value from my PHP code

    Create a C function responsible of expanding the constant name to the desired value then register it using the ph7_create_constant() interface. After that the installed constant can be expanded from your PHP code.

    See this tutorial for additional information.


  10. How can I extract array entries values inside my foreign function

    Create a walker callback first then invoke it using a call to the ph7_array_walk() interface or call the ph7_array_fetch() interface to fetch a single array entry value.

    See this tutorial for additional information.


  11. How can I extract object attributes values inside my foreign function

    Create a walker callback first then invoke it using a call to the ph7_object_walk() interface or call the ph7_object_fetch_attr() interface to fetch a single object attribute value.

    See this tutorial for additional information.


  12. How can I return a array from my foreign function

    Inside your C function, create a new array using the ph7_context_new_array() interface, populate your freshly created array using one more calls to ph7_array_add_elem() and/or it's wrapper interfaces. When done return the created array using the ph7_result_value() interface.

    See this tutorial for additional information.


  13. How can I configure my virtual machine with a HTTP request

    First off, read the full HTTP request from the connected peer using the standard system calls such as read() or recv(). After that you must configure your virtual machine using the ph7_vm_config() interface with a configuration verb set to PH7_VM_CONFIG_HTTP_REQUEST with the HTTP request just read. Now you can extract HTTP request information from your PHP code using the $_GET, $_POST, $_SERVER arrays or any other related variables.


  14. How can I perform an echo call in my foreign function

    Inside your C function, simply call ph7_context_output() or ph7_context_output_format() with the desired message to output.

    See this tutorial for additional information.


  15. How can I throw an error in my foreign function

    Inside your C function, simply call ph7_context_throw_error() or ph7_context_throw_error_format() with the desired error message to output.

    See this tutorial for additional information.


  16. How can I stop program execution inside my foreign function

    If something goes wrong while performing the computation inside your installed foreign function and you want to abort the virtual machine execution immediately, simply return PH7_ABORT instead of PH7_OK.

    See this tutorial for additional information.


  17. Is PH7 thread-safe

    Threads are evil. Avoid them.

    PH7 is threadsafe. We make this concession since many users choose to ignore the advice given in the previous paragraph. But in order to be thread-safe, PH7 must be compiled with the PH7_ENABLE_THREADS compile time directive defined. If you are unsure if the PH7 library you are linking against is compiled to be threadsafe you can call the ph7_lib_is_threadsafe() interface to find out.


  18. How can I return a multi-dimensional array in my foreign function

    Inside your C function, create a new array using the ph7_context_new_array() interface, then create another array using the same interface. After that populate the second array with the desired values (including other arrays). When done insert the second array in the first one using one or more calls to ph7_array_add_elem() and/or it's wrapper interfaces. When done return the created array using the ph7_result_value() interface.

    See this tutorial for additional information.


  19. How can I contribute to the PH7 development

    PH7 is an open-source project open to every one and we are looking for C developers to enhance the engine especially in the implementation of a standard library that includes DB, regex, network functions and more.

    The project is in heavy development and any contribution is very welcome, so if you want to involve in the PH7 development process, please sign-up and post a message in the PH7 devel mailing list or send an email to devel@symisc.net

    If you have/can write a wrapper/binding for a foreign programming language, again post a message in the PH7 forums or the devel mailing list or send an email to devel@symisc.net


  20. Where can I report bugs

    You can report bugs in the PH7 mailing list, the PH7 forums or the online bug tracker. Check the support page for additional information.


Symisc Systems
Copyright © Symisc Systems