-
Notifications
You must be signed in to change notification settings - Fork 38
/
PHP_Building_Guide_for_Windows.txt
48 lines (29 loc) · 4 KB
/
PHP_Building_Guide_for_Windows.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
This document shows a simple guide on how to build PHP bindings of PDFNet for Windows. Keep in mind that this document was written for a specific release of PHP so some information may not apply to the version of PHP you are attempting to build a binding for. Additional dependencies may also be necessary in the future.
1. Download development package for Windows PHP here: http://windows.php.net/downloads/releases/. For this guide, we will download the following: http://windows.php.net/downloads/releases/php-devel-pack-5.6.11-nts-Win32-VC11-x86.zip. Keep in mind that this is version 5.6.11 non-threadsafe 32-bit for Visual Studio 2012. This means that you will need the same version of runtimes to get the samples to work (i.e. PHP 5.6.11 NTS 32-bit binaries, VS2012 runtimes, 32-bit PDFNetC).
2. Because we just obtained x86 of PHP, we want to also obtain the required PDFNetC which must be 32-bit as well: https://www.pdftron.com/downloads/PDFNetC.zip (For x64, please obtain `PDFNetC64` from https://www.pdftron.com/downloads/PDFNetC64.zip)
3. Download the Github repository for the wrappers: https://github.com/ApryseSDK/PDFNetWrappers/archive/master.zip
4. Download and install CMake: http://www.cmake.org/download/ (it does not matter which version)
5. Download SWIG: http://prdownloads.sourceforge.net/swig/swigwin-3.0.6.zip
6. Few notes to keep in mind before proceeding:
6.a: Because the PHP is compiled using VC11, make sure your system has VC11 (Visual Studio 2012) installed to compile and link the PDFNet bindings for this version of PHP.
6.b: Make sure that the PHP package you downloaded contains "dev/php5.lib" file. This is the linkage file for the version of PHP you downloaded.
7. Extract the Github repository file: PDFNetWrappers-master.zip. Let us call this the GITHUB_REPO_DIR.
8. Extract PDFNetC.zip (or PDFNetC64.zip for x64). Copy both the "Headers" and "Lib" folders into GITHUB_REPO_DIR/PDFNetC. You should have:
* GITHUB_REPO_DIR/PDFNetC/Headers/...
* GITHUB_REPO_DIR/PDFNetC/Lib/...
9. Extract the PHP development package. Let us call the extracted folder as PHP_DEVEL_DIR
10. Extract swig, let us call the extracted folder as SWIG_DIR, add SWIG_DIR to PATH environment variable
11. Go to GITHUB_REPO_DIR/Build (create the directory if it does not exist) and run CMake using following cmake variables:
> BUILD_PDFNetPHP = ON
> PHP_INCLUDE_DIRS = PHP_DEVEL_DIR/include;PHP_DEVEL_DIR/include/ext;PHP_DEVEL_DIR/include/ext/date/lib;PHP_DEVEL_DIR/include/main;PHP_DEVEL_DIR/include/sapi;PHP_DEVEL_DIR/include/TSRM;PHP_DEVEL_DIR/include/win32;PHP_DEVEL_DIR/include/Zend
> PHP_LIBRARY = PHP_DEVEL_DIR/lib/php5.lib
Make sure you replace "PHP_DEVEL_DIR" with the correct path to the extracted development package directory.
Your command should look like below:
> cmake.exe -G "Visual Studio 11" -DBUILD_PDFNetPHP=ON -DPHP_INCLUDE_DIRS=PHP_DEVEL_DIR/include;PHP_DEVEL_DIR/include/ext;PHP_DEVEL_DIR/include/main;PHP_DEVEL_DIR/include/sapi;PHP_DEVEL_DIR/include/TSRM;PHP_DEVEL_DIR/include/win32;PHP_DEVEL_DIR/include/Zend -DPHP_LIBRARY=PHP_DEVEL_DIR/lib/php5.lib
You may need to set SWIG_DIR as environment variable as necessary. Or pass the cmake variable SWIG_EXECUTABLE if CMake cannot find swig.
You may also optionally use the GUI front-end of CMake to make things simpler. The options must look like below:
12. The Visual Studio project should have been generated at the GITHUB_REPO_DIR/Build. Build the project (it is better to build it in release so that it will use the same VC runtime builds as the PHP binaries).
13. The following files should be created after building the project:
* GITHUB_REPO_DIR/Build/lib/PDFNetPHP.php
* GITHUB_REPO_DIR/Build/lib/Release/PDFNetPHP.dll
14. You can now use these files to run the PDFNetC samples. You will need to make sure to add PDFNetPHP.dll as a PHP extension in your php.ini file. Then also make sure that PDFNetC.dll can be found by php.exe. If you are able to run "php -i" successfully, then it means that PDFNetPHP extension works.