background:
The last two columns are all about the building of the Web PACs environment, if the platform back-end does not carry out dicom related operations, in fact, there is no relationship with PACs, so the recent several seemingly somewhat off-topic, but we do not worry, The construction of the development environment itself is a huge and difficult project, such as debugging a good environment follow-up PACS related development will be as handy as a standalone version, and then endure a while, will soon begin to introduce the development of Web PACs on the platform.
build the environment for PHP extensions in C + +:
The two blog post is just a trickery attempt to the environment, the first blog post directly using the Apache service from the CGI, directly call C compiled EXE file, because CGI technology has gradually been replaced by fastcgi, so the first blog post only as a demonstration to use, not applied to the actual development of the late The second post continues the first article, trying to carry out the image transmission, and finally can not find the C language to achieve the correct method of image data transmission, can only be lazy in PHP and Perl and other interpreted language to achieve, but PHP and Perl can not be very good with the DCMTK we described earlier fusion, So the second blog post doesn't have much effect. In view of the above reasons, it is decided to build the FastCGI platform, and then add the C + + language to write the framework of PHP extension to achieve the complete development environment of the final Web PACs.
Pre-Preparation:
1 PHP Source : The purpose of downloading PHP source code is to generate the latest, most in line with the PHP running program, that is Php.exe (of course, you can also directly Baidu/Google the latest PHP installation package, double-click Install can);
2) PHP source code compiled : PHP source code is open source, requires compiling under Linux, so you need to install a mini Linux compilation environment under Windows, that is, download Cygwin or msys+ Minggwen (The detailed differences between the two can be referred to in this blog http://zengrong.net/post/1723.htm);--Remember that after the installation is complete Cygwin (i.e. the Linux compiler), modify the ext_skel_win32.php $cygwin _path = ' c:\cygwin64\bin '; The statement is changed to its own path in order to indicate the location of the Sh.exe.
3) PHP SDK: SDK, all called software Development Kit, as the name implies is the software development process commonly used small tools (can be understood as the API) collection. Here we only need to use the Bison.exe and Flex.exe in the PHP-BINARY-SDK package to copy it to the current Windows directory-The purpose is for us to find (or add both paths to the environment variable path).
Compile Build:PHP Source code compilation:
This computer is installed VS2012 and VS2010, here choose VS2012 to compile PHP source code. First enter the command line state of VS, such as:
Input:CD c:\PHPDev\php-5.6.2
Switch to the PHP source directory, which has the Buildconf.bat file. (Here Phpdev is my own establishment of the first level of the directory, in the actual compilation process, please replace the local directory)
Input:buildconfig.bat, which starts the script in the batch command buildconfig.js, searches for all the. w32 files in the directory to prepare for compilation in the Windows environment. If the run succeeds it will prompt "now run ' Configure--help '", otherwise prompt "Error generating configure script, configure script is not copied". After successful compilation, follow the prompts to enter configure--help to view the compilation options, and then refer to blog post http://demon.tw/software/compile-php-on-windows.html for instructions to enter:
CONFIGURE–WITHOUT-XML–WITHOUT-WDDX--without-simplexml--without-dom--without-libxml--disable-zlib-- without-pdo-sqlite–-disable-odbc–-disable-cgi--enable-debug--without-iconv--disable-ipv6
Note here is slightly different from the introduction of blog post, without is two "-", specific reference configure--help tips, such as:
After the configuration is complete, the compilation process is completed, and the input NMAKE begins the actual compilation.
Note: Errors may occur during compilation, such as in the case of an edit tool such as EditPlus or notepad++ that dumps the file to Utf-8 encoding and restarts nmake.
After compiling, the Debug_ts folder will appear, which is the PHP executable that we generated after compiling the source code, which will see the Php.exe file, which is the result diagram of NMAKE compiling successfully.
Go to the Debug_ts directory and enter Php.exe "Echo ' Hello world '; The test can see the correct output, the work of compiling PHP source code under the Windows platform has been completed successfully.
PHP Skeleton Generation:
Php.exe ext_skel_win32.php--extname=zsgetdcmimage
Once the PHP executable is obtained, the skeleton is generated. Enter the PHP source in the Ext folder, you can see the skeleton generated by the two files, Ext_skel and ext_skel_win32.php. Open ext_skel_win32.php, in general can see how to build Skeleton program, in fact, through the Cgywin provided in the Sh.exe tool, start Sh.exe Ext_skel, and then will have been written in a C/s based The project of the dynamic library is automatically modified by the PHP script to the project we named. can open the source code Ext\skeleton directory, found that there is a name called SKELETON.DSP project, and ultimately we get the skeleton project is only a different name.
C Write the PHP extension test:
The basic environment is set up, let's do a real test.
The skeleton project provides us with a test function that is the same as our project name, for example, the functions in my Zsgetdcmimage project are:
/* Remove The following function when you have successfully modified CONFIG.M4 so, your module can be compiled int o PHP, it exists only for testing purposes. *//* every user-visible function in PHP should document itself in the sour Ce *//* {{proto string confirm_zsgetdcmimage_compiled (string arg) Return A string to confirm this module is comp Iled in */php_function (confirm_zsgetdcmimage_compiled) {char *arg = Null;int Arg_len, Len;char *strg;len = spprintf (& STRG, 0, "congratulations! You have successfully modified EXT/%.78S/CONFIG.M4. Module%.78s is now compiled into PHP. "," Zsgetdcmimage ", Arg); Return_stringl (STRG, Len, 0);}
Because the PHP source we compiled above is the debug state, that is, the parameter is--enable-debug, so in writing skeleton program at the moment to correspond to the DEBUG_TS mode of compiling, while adding the link library is Php5ts_ Debug.lib, the file is in the PHP compiled source folder Debug_ts.
After the compilation succeeds, copy the generated zsgetdcmimage.dll to the EXT subdirectory in the directory of our compiled PHP executable debug_ts, then modify the php.ini in Debug_ts, add extension=ext/ The Zsgetdcmimage.dll statement.
Finally, create a test PHP document test.php with the following code:
<?phpecho confirm_zsgetdcmimage_compiled ("zssure");? >
In the command line state, go to the Debug_ts directory, enter Php.exe test.php, if the configuration is successful, you will get the following output:
The skeleton extension and the instance test are now complete.
PostScript: replace PHP in Wampserver
The first two blogs have used Wamp to fight an opportunity Apache+php+mysql Web services framework that puts the above compiled Zsgetdcmimage.dll extensions into C:\wamp\bin\php5.5.12\ext, After you start Wampserver, you cannot invoke the following error message:
This error indicates that the extensions generated with the php5.6.2 extension skeleton do not match under php5.5.12. In this case, to add the PHP extension skeleton to the previous Web PACs platform only two options: 1) re-download the corresponding version of the php5.5.12 source, follow the above record to regenerate the skeleton program, 2) Replace the WAMP installation package PHP.
Originally the configuration of wampserver is not very understanding, so I want to use this opportunity to learn by the way. Then decided to try to replace PHP in the Wampserver installation package, with the original php5.5.12 replaced with php5.6.2. Online search for a bit, the relevant information a lot. Basic operating ideas are mainly referred to the two blog post of the introduction of http://www.cnblogs.com/heiing/archive/2011/11/15/2249948.html and http://pcwanli.blog.163.com/ blog/static/45315611201441811572810/, the introduction of the two blog post is simple, and the logic is not very good. Now give me the concrete implementation steps in the WIN7 32bit+wampserver-64-bits-php-5-5 environment. First, you will go to the c:\wamp\bin\php directory and extract the latest Windows binaries downloaded from the PHP website into this directory, for example, the full path of php5.6.2 is C:\wamp\bin\php\ php5.6.2, then modify the method and order as follows:
Wampserver Modification 1 |
Wampmanager.conf |
The [PHP] tab is replaced with the new version number 5.6.2 Replace the version number in the [PHPCLI] label with 5.6.2 |
Wampserver Modification 2 |
Wampmanager.ini |
Use a text editor such as notepad++ or editplus to search for phpx.x.x in a file and replace it with php5.6.2; Note: The x.x.x section also needs to be replaced with 5.6.2, for example, caption under [switchPhp5.6.2],[phpversion] , and so on. |
PHP changes 1 |
Ini |
1) Set Extension_dir as the path to the new version of Php.exe, Extension_dir = "c:\wamp\bin\php\php5.6.2\ext\" 2) then selectively uncomment extension=xxx.dll, add PHP extensions |
PHP Changes 2 |
Phpforapache.ini |
Copy the php.ini file and rename it to Phpforapache.ini |
APACEH modify |
httpd.conf |
The version number of PHP in the fastcgi configuration module is modified accordingly, as follows: LoadModule php5_module c:/wamp/bin/php/php5.6.2/ Php5apache2_4.dll " Phpinidir c:/wamp/bin/php/php5.6.2 LoadModule fcgid_module modules/mod_fcgid.so <ifmodule mod_fcgid.c> AddHandler fcgid-script. fcgi. php #php. ini Storage directory Fcgidinitialenv PHPRC "c:/wamp/bin/php/php5.6.2" # set php_fcgi_max_requests greater than or equal to fcgidmaxrequestsperprocess, Prevents the php-cgi process from exiting the fcgidinitialenv php_fcgi_max_requests #php-cgi The maximum number of requests per process Before all requests are processed Fcgidmaxrequestsperprocess #php-cgi Maximum number of processes Fcgidmaxprocesses 5 #最大执行时间 Fcgidiotimeout Fcgididletimeout #php path to-cgi Fcgidwrapper c:/wamp/bin/php/php5.6.2/ Php-cgi.exe ". PHP AddType application/x-httpd-php. php </ifmodule> |
Actual test |
1) put Zsgetdcmimage.dll extensions compiled with PHP skeleton into the Php5.6.2\ext directory 2) Build the test php file in the wamp\www directory, test.php |
Enter localhost\test.php in the browser Get the following output: |
At this time to replace the PHP version of the Wampserver installation package completed successfully, after several efforts, with three blog space we have successfully built the Web PACs development of the basic environment. The following will begin to introduce the use of PHP extension skeleton combined with DCMTK to achieve the various functions of Web PACs.
Follow-up Column blog introduction:
Develop Web PACs applications with PHP Skel combined with DCMTK
Using DCMTK to build WML servers
Direct operation of DICOM data with Oracle
Application of the asynchronous programming pattern of C # in fo-dicom
Practical testing of VMware three network connection modes
[email protected]
Date: 2014-10-31
DICOM Medical image processing: WEB PACs in the first three, PHP extension skeleton