title: PHP 5.4.7 Compiling ext php_printer
body: <p>My Knowledge base is, I can get around in php. I never worked with C, C++, C# or any compilers.</p>
  
  <p>I Upgraded from XAMPP 1.7.3, which used php 5.3, to 1.8.1 which includes:
  Apache 2.4.3
  MySQL 5.5.27
  PHP 5.4.7</p>
  
  <p>It is being installed on Windows 7 Pro, Windows XP Pro and Windows Server 2008 r2. But I am trying to get it to working on Windows 7 currently.</p>
  
  <p>I upgraded because I needed a newer version of Apache and MySQL for security reasons. I do not have the option to downgrade. </p>
  
  <p>I use the php_printer.dll for the ability to print raw data to the printer:</p>
  
  <pre><code>printer_set_option($handle, PRINTER_MODE, "RAW");
  </code></pre>
  
  <p>My Code worked fine in PHP 5.3 but broke in PHP 5.4.</p>
  
  <p>After receiving the error: " Fatal error: Call to undefined function printer_open() in ~". I checked the php_error_log and received the following information.</p>
  
  <pre><code>PHP Warning: PHP Startup: printer: Unable to initialize module
  Module compiled with module API=20090626
  PHP compiled with module API=20100525
  These options need to match
  </code></pre>
  
  <p>I've looked for hours trying to find a pre-compiled php_printer.dll for PHP 5.4.7 to no avail. I have concluded that I will have to compile it from source files in the PECL. pecl.php.net/package/printer</p>
  
  <p>Having never had to do this before I did what any internet user should do. I googled it and found some information here:
  <a href="https://wiki.php.net/internals/windows/stepbystepbuild" rel="nofollow">https://wiki.php.net/internals/windows/stepbystepbuild</a></p>
  
  <p>It took me all day but the PHP build worked. But then tried to create the php_printer.dll
  First I tried : </p>
  
  <pre><code>svn co http://svn.php.net/repository/pecl/printer/trunk pecl/printer
  </code></pre>
  
  <p>But it said: 
      'svn' is not recognized as an internal or external command, operable program or batch file.</p>
  
  <p>So I just downloaded the files myself from:
  <strong>svn.php.net/repository/pecl/printer/trunk/</strong>
  and put them in:
  <strong>C:\php-sdk\php54dev\vc9\x86\php5.4-201303311430\ext\printer</strong></p>
  
  <p>I made sure to download the libraries both from:
  <strong>windows.php.net/downloads/php-sdk/deps/vc9/x86/</strong>
  Also just the:
  <strong>deps-5.4-vc9-x86.7z</strong></p>
  
  <p>I tried one then the other, however; every time I received the following when I tried to nmake:</p>
  
  <pre><code>c:\php-sdk\php54dev\vc9\x86\php5.4-201303311430&gt;nmake
  
  Microsoft (R) Program Maintenance Utility Version 9.00.30729.01
  Copyright (C) Microsoft Corporation.  All rights reserved.
  
  printer.c
  ext\printer\printer.c(266) : error C2065: 'pval' : undeclared identifier
  </code></pre>
  
  <hr>
  
  <p>UPDATE</p>
  
  <p>I got some help on another forum.</p>
  
  <hr>
  
  <p>by hackattack142 » 03. April 2013 23:51</p>
  
  <p>Hello,</p>
  
  <p>Open 'printer.c' and replace all instances of 'pval' with 'zval' and it should compile.</p>
  
  <hr>
  
  <p>Thank you Hackattack, one step closer I hope,</p>
  
  <pre><code>c:\php-sdk\php54dev\vc9\x86\php5.4-201303311430&gt;buildconf
  ~
  c:\php-sdk\php54dev\vc9\x86\php5.4-201303311430&gt;configure --disable-all --enable-cli 
  --enable-printer
  ~
  c:\php-sdk\php54dev\vc9\x86\php5.4-201303311430&gt;nmake
  
  Microsoft (R) Program Maintenance Utility Version 9.00.30729.01
  Copyright (C) Microsoft Corporation.  All rights reserved.
  
  internal_functions.c
  printer.c
     Creating library Release_TS\php5ts.lib and object Release_TS\php5ts.exp
     Creating library Release_TS\php.lib and object Release_TS\php.exp
  SAPI sapi\cli build complete
  </code></pre>
  
  <p>It seemed to have compiled. However; I can't find a printer.dll or a php_printer.dll which is the outcome I was hoping for. </p>
  
  <p>In the <strong>Release_TS\ext</strong> folder there is a folder named <strong>Printer</strong>. It contains the following Files:
  <strong>printer.obj
  printer.sbr
  vc90.idb</strong></p>
  
  <p>I also did the last step:</p>
  
  <pre><code>c:\php-sdk\php54dev\vc9\x86\php5.4-201303311430&gt;cd Release_TS
  c:\php-sdk\php54dev\vc9\x86\php5.4-201303311430\Release_TS&gt;php -m
  [PHP Modules]
  Core
  date
  ereg
  pcre
  printer
  Reflection
  SPL
  standard
  [Zend Modules]
  c:\php-sdk\php54dev\vc9\x86\php5.4-201303311430\Release_TS&gt;
  </code></pre>
  
  <hr>
  
  <p>Help from another forum</p>
  
  <pre><code>configure --disable-all --enable-cli --enable-printer=shared
  </code></pre>
  
  <p>It worked and i created the php_printer.dll however when i tried to use it:</p>
  
  <p>In PHP Error Log:
  [15-Apr-2013 15:34:53 UTC] PHP Warning: PHP Startup: Invalid library (maybe not a PHP library) 'php_printer.dll' in Unknown on line 0</p>
  
  <hr>
  
  <p>I had to grab 5.4.7 files as I was using 5.4.15 but XAMPP 1.8.1 uses 5.4.7</p>
  
  <p><a href="http://www.oldapps.com/php_programming_language.php?old_php=8227" rel="nofollow">http://www.oldapps.com/php_programming_language.php?old_php=8227</a></p>
  
  <p>And put it in: C:\php-sdk\php54dev\vc9\x86\php-5.4.7</p>
  
  <p>then put the printer files in the ext folder and did all the above processes and:</p>
  
  <p>configure --enable-printer=shared</p>
  
  <p><strong>And it worked:</strong></p>
  
  <p><strong>PHP Version 5.4.7 php_printer.dll</strong></p>
  
  <p><strong><a href="http://pylonx.com/PHP/php_printer_5.4.7.zip" rel="nofollow">http://pylonx.com/PHP/php_printer_5.4.7.zip</a></strong></p>