Archived

This forum has been archived. Please start a new discussion on GitHub.

Ice with PHP

Hi all,

I have a question, I have compiled Ice for PHP and received file IcePHP.dy instead of IcePHP.so.

Can anyone please spend explain how to use it and actually connect with php?

Thanks!

Comments

  • mes
    mes California
    Hi,

    The php/INSTALL file in the Ice source distribution contains instructions for installing the extension. This file does not contain instructions for Mac OS since that is not a supported platform for our PHP extension, but the instructions for Linux might help you to get it working.

    Regards,
    Mark
  • Thanks, mes!

    I have read that file, but there is no single word about IcePHP.dy file, that's why I am asking.

    Please help if you know anything about it.

    Thanks again!
  • mes
    mes California
    IcePHP.dy is the shared library for the Ice extension. It is the equivalent of IcePHP.so on Linux.

    Regards,
    Mark
  • thanks a lot for the reply.

    now I added my php.ini with line
    extension=/opt/Ice-3.4.1/php/IcePHP.dy

    and when I use php I am getting warning:
    Warning: PHP Startup: Unable to load dynamic library '/opt/Ice-3.4.1/php/IcePHP.dy' - dlopen(/opt/Ice-3.4.1/php/IcePHP.dy, 9): Library not loaded: /opt/Ice-3.4/lib/libIce.34.dylib
    Referenced from: /opt/Ice-3.4.1/php/IcePHP.dy
    Reason: image not found in Unknown on line 0

    I am using php5.3.4-dev

    please advice where I am wrong. Thanks!
  • bernard
    bernard Jupiter, FL
    Hi Oksana,

    It's looking for your Ice for C++ shared libraries in their default location (/opt/Ice-3.4). If you installed Ice for C++ somewhere else, you could create a symbolic link.

    Cheers,
    Bernard
  • Hi Bernard!

    Super thanks for the reply.
    Can you please take a quick look into this error

    Call to undefined function Ice_loadProfile()
    but when I do
    php -m
    I can see ice there

    hash
    ice
    iconv

    I have added t php.ini as well (file exists)
    ice.slice = slice.ice

    from phpinfo() I can see
    ice

    [HTML]Ice support enabled
    Ice version 3.4.1

    Directive Local Value Master Value
    ice.con no value no value
    ice.hid 1 1
    ice.opt no value no value
    ice.pro no value no value[/HTML]
  • oh, I found
    I should use
    [PHP]
    require_once 'Ice.php';
    $ICE = Ice_initialize();
    [/PHP]
  • bernard
    bernard Jupiter, FL
    Hi Oksana,

    Good to hear you figure it out!

    Once you have Ice for PHP working on your Mac, it would be great if you could post step by step instructions, and maybe a patch (if code changes were needed). I am sure other Ice for PHP users would be interested.

    Thanks,
    Bernard
  • Hi Bernard,
    yes of course.
      What we need

      # MacOS X (Intel 32 bit & 64 bit) Archive
      Ice-3.4.1-bin-macosx.tar.gz

      # Source Distributions
      Ice-3.4.1.tar.gz
        Setup Process


        1. You have to compile Ice for C++ first.
        The easiest will be just untar Ice-3.4.1-bin-macosx.tar.gz and set ICE_HOME

        [PHP]ICE_PATH=/path/to/Ice/bin[/PHP]

        2. Untar Ice-3.4.1.tar.gz

        [PHP]cd php/config[/PHP]

        3. Edit Makefile.rules.php file (change path to your php installation/use namespaces/ feel free

        [PHP]PHP_HOME = /etc/apache2/php[/PHP]

        4. Copy Makefile.rules.Darwin from cpp folder to php

        [PHP]cp cpp/config/Makefile.rules.Darwin php/config[/PHP]

        5. Edit Makefile.rules.Darwin

        [PHP]\#LDPLATFORMFLAGS \+= \-rdynamic
        LDPLATFORMFLAGS = \-Wl,-bind_at_load
        \#ifdef ice_src_dist
        \# shlibldflags = $(CXXFLAGS) \-L$(libdir)
        \#else
        \# shlibldflags = $(CXXFLAGS) \-L$(ice_dir)/$(libsubdir)
        \#endif
        shlibldflags = $(CXXFLAGS) ${wl}\-flat_namespace ${wl}\-undefined ${wl}suppress \-L$(libdir)[/PHP]

        6. Follow the sun (README) file

        [PHP]./configure
        make
        make install[/PHP]

        7. And now you should have shared library for the Ice extension in a path specified by prefix variable in you Make.rules.php file.

        8. Connect your php with Ice installation. Add to you php.ini file

        [PHP]extension=/opt/Ice-3.4.1/php/IcePHP.dy[/PHP]

        9. Set DYLD_LIBRARY_PATH variable

        [PHP]DYLD_LIBRARY_PATH=/path/to/ice/lib[/PHP]

        10. Check loaded modules (php -m) or
        [PHP]
        phpinfo();[/PHP]

        11. Enjoy your Ice


          Good to know.

          There is a difference in initializing connection between Ice 3.3.x and 3.4.x

          Ice <= 3.3

          [PHP]Ice_loadProfile();
          // initialize ice connection
          global $ICE;
          $base = $ICE->stringToProxy('$proxy');[/PHP]

          Ice >= 3.4

          For Ice 3.4 and later you’ll have to do a different approach.

          [PHP]require_once 'Ice.php';
          $ICE = Ice_initialize();
          $meta = $ICE->stringToProxy('$proxy');[/PHP]