PHP 5.4.7 Compiling ext php_printer

11,300

Solution 1

Download and install any version of php you like and install the appropriate php printer dll here: http://windows.php.net/downloads/pecl/snaps/printer/0.1.0-dev/

Solution 2

It's a bug in versions 5.4.7 to 5.4.11 of PHP.

Share:
11,300
dBaker
Author by

dBaker

Updated on June 02, 2022

Comments

  • dBaker
    dBaker about 2 years

    My Knowledge base is, I can get around in php. I never worked with C, C++, C# or any compilers.

    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

    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.

    I upgraded because I needed a newer version of Apache and MySQL for security reasons. I do not have the option to downgrade.

    I use the php_printer.dll for the ability to print raw data to the printer:

    printer_set_option($handle, PRINTER_MODE, "RAW");
    

    My Code worked fine in PHP 5.3 but broke in PHP 5.4.

    After receiving the error: " Fatal error: Call to undefined function printer_open() in ~". I checked the php_error_log and received the following information.

    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
    

    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

    Having never had to do this before I did what any internet user should do. I googled it and found some information here: https://wiki.php.net/internals/windows/stepbystepbuild

    It took me all day but the PHP build worked. But then tried to create the php_printer.dll First I tried :

    svn co http://svn.php.net/repository/pecl/printer/trunk pecl/printer
    

    But it said: 'svn' is not recognized as an internal or external command, operable program or batch file.

    So I just downloaded the files myself from: svn.php.net/repository/pecl/printer/trunk/ and put them in: C:\php-sdk\php54dev\vc9\x86\php5.4-201303311430\ext\printer

    I made sure to download the libraries both from: windows.php.net/downloads/php-sdk/deps/vc9/x86/ Also just the: deps-5.4-vc9-x86.7z

    I tried one then the other, however; every time I received the following when I tried to nmake:

    c:\php-sdk\php54dev\vc9\x86\php5.4-201303311430>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
    

    UPDATE

    I got some help on another forum.


    by hackattack142 » 03. April 2013 23:51

    Hello,

    Open 'printer.c' and replace all instances of 'pval' with 'zval' and it should compile.


    Thank you Hackattack, one step closer I hope,

    c:\php-sdk\php54dev\vc9\x86\php5.4-201303311430>buildconf
    ~
    c:\php-sdk\php54dev\vc9\x86\php5.4-201303311430>configure --disable-all --enable-cli 
    --enable-printer
    ~
    c:\php-sdk\php54dev\vc9\x86\php5.4-201303311430>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
    

    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.

    In the Release_TS\ext folder there is a folder named Printer. It contains the following Files: printer.obj printer.sbr vc90.idb

    I also did the last step:

    c:\php-sdk\php54dev\vc9\x86\php5.4-201303311430>cd Release_TS
    c:\php-sdk\php54dev\vc9\x86\php5.4-201303311430\Release_TS>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>
    

    Help from another forum

    configure --disable-all --enable-cli --enable-printer=shared
    

    It worked and i created the php_printer.dll however when i tried to use it:

    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


    I had to grab 5.4.7 files as I was using 5.4.15 but XAMPP 1.8.1 uses 5.4.7

    http://www.oldapps.com/php_programming_language.php?old_php=8227

    And put it in: C:\php-sdk\php54dev\vc9\x86\php-5.4.7

    then put the printer files in the ext folder and did all the above processes and:

    configure --enable-printer=shared

    And it worked:

    PHP Version 5.4.7 php_printer.dll

    http://pylonx.com/PHP/php_printer_5.4.7.zip