Zorba with PHP 5 - Windows Installation
These steps were checked on Windows 7.It should work fine with any PHP 5.X version and any other W32 platform.
Install PHP5
Download and install PHP5 from
http://windows.php.net/download/. Remember to download and install according your VC version.PHP will automatically install itself in to your apache server. If you got Apache from Apache Lounge you may need their PHP module version.You can verify your install by adding a file in your htdocs directory with the following code:
<strong>info.php</strong>
<?php
phpinfo();
?>
Compiling the Zorba PHP Extension
If you are compiling Zorba, you will need also to compile the PHP Wrapper, to do this you besides the
Zorba Build Instructions you need to add these three variables to your CMAKE command line:
-D PHP5_BINARY_DIR=[PHP INSTALL]
[PHP INSTALL] is the directory where php.exe is located, i.e. "C:\php"
-D PHP5_INCLUDE_DIR=[PHP INCLUDE DIR]
[PHP INCLUDE DIR] is the directory where the php source is located, i.e. "C:\php-5.3.5"
-D PHP5_LIBRARY=[PHP LIBRARY]
[PHP LIBRARY] is the path where the php5ts.lib is located, this file is usually located in dev directory from the binary php installation, i.e. "C:/php/dev/php5ts.lib"
After adding those lines CMAKE will add automatically the PHP Wrapper project and you will be able to get zorba_api.dll, which is the extension you can use in your php binary installation.
Verify Zorba
Check Zorba is working by command line:
C:\zorba.exe -q '2+1'
<?xml version="1.0" encoding="UTF-8"?>
3
Enable Zorba extension in PHP
Copy Zorba extension zorba_api.dll file into your php extensions directory, this extension is located on: Zorba compiled from sources: [ZORBA BUILD DIRECTORY]\[DEBUG/RELEASE IF VISUAL STUDIO] Zorba installed binaries: [ZORBA INSTALL DIRECTORY]\this file must be copied to your extensions directory that may be:
C:\php\ext\
Modify your php.iniAdd the following line to php.ini
extension=zorba_api.dll In your Zorba directory, locate the files zorba_api_wrapper.php and XQueryProcessor.php, copy them it to your include directory from where php can find it, this location is set on your php.ini file with the name <cope>include_path, i.e.
; Windows: "\path1;\path2" include_path = ".;C:\php\include" Restart Apache Http server Refresh your browser with previous info file:
http://localhost/info.phpCheck if zorba_api is in the list of php known extensions.
Verify it works
Add the following content in to a file on your htdocs directory:
test.php <html>
<title>Zorba test</title>
<body>
<?php
require_once 'zorba_api_wrapper.php';
$ms = InMemoryStore::getInstance();
$zorba = Zorba::getInstance($ms);
try {
$queryStr = '1+2';
$query = $zorba->compileQuery($queryStr);
$result = $query->execute();
echo $result;
$query->destroy();
$zorba->shutdown();
InMemoryStore::shutdown($ms);
} catch (Exception $e) {
die('ERROR:' . $e->getMessage());
}
?>
</body>
</html>
Point your browser to
http://localhost/test.php and see the result.