i'm trying to install amfext.

I have a mac that I use as a development server. I installed MAMP to develop web apps and it seems entirely satisfactory as it allows me to select PHP 5.3.2 as its PHP version (the other option being 5.2.13).

However, when I run php from the command it reports a version of 5.2.12:

My-Mac:~ sneakyimp$ php -v
PHP 5.2.12 (cli) (built: Feb  9 2010 00:34:23)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies

I have no idea how this particular version got installed on my machine -- unless it was put there by MAMP.

I renamed /usr/bin/php to /usr/bin/phpOLD and then created a symbolic link to the MAMP version of php 5.3.2:

sudo ln -s /applications/mamp/bin/php5.3/bin/php /usr/bin/

Now when I run php-v, I get what I thought I should:

My-Mac:~ sneakyimp$ php -v
PHP 5.3.2 (cli) (built: Mar  5 2010 16:45:34)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with XCache v1.3.0, Copyright (c) 2005-2009, by mOo

Q1: Does anyone see any problem with this?

I tried to run a pecl install. It complained about no stable version so I tried the beta version:

 sudo pecl install amfext channel://pecl.php.net/amfext-0.9.2

This appeared to run an installation but when it finished, it reported this:

Build process completed successfully
Installing '/usr/lib/php/extensions/no-debug-non-zts-20060613/amf.so'

I haven't the slightest clue where it got that extension directory from! Command line php reports an extension_dir of /Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626/

Jason-Mac:~ christopherwalsh$ php -i | grep extension_dir
extension_dir => /Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626/ => /Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626/

When I look at the output of 'pecl config-show', I get another extension_dir entirely:

/Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-20050922

Q2: What on earth is up with my system? Can anyone recommend how to clean this mess up?

    sneakyimp wrote:

    I haven't the slightest clue where it got that extension directory from!

    PECL has its own configuration that you set when you first install it. Do a "pecl help" and look for an option to list (and/or change) the PECL configuration.

    sneakyimp wrote:

    Can anyone recommend how to clean this mess up?

    Yeah; get rid of that MAMP crap and install PHP manually so you know that everything gets setup properly. :p

      I tried updating both the pecl and pear config files with "pecl config-set". Despite the fact that these values now all reflect the MAMP install, pecl still tries to install amfext in /usr/lib/php/extensions/no-debug-non-zts-20060613/amf.so. I finally found that this value was stored in what appeared to be a text file: /usr/bin/php_config. I renamed the file and now I get this:

      configure: error: Cannot find php-config. Please use --with-php-config=PATH
      ERROR: `/private/tmp/pear/cache/amfext-0.9.2/configure' failed
      
      bradgrafelman wrote:

      Yeah; get rid of that MAMP crap and install PHP manually so you know that everything gets setup properly.

      Good lord that's a terrifying prospect. I've done server config on debian and centOS where you have APT-GET and YUM but those don't exist on a Mac. The idea of acquiring all the source and compiling it meself sounds like days of effort.

        What do you mean you "renamed" the file? It obviously needs to use that file to get the correct values, so I'm not sure how taking away that file altogether is supposed to help? :p

        Have you tried simply downloading the source and compiling it manually? Just go here, download the latest version, extract it somewhere, and run these commands in that directory:

        phpize
        ./configure
        make install

        Note that you'll have to first fix your php-config file to point to the correct locations.

        sneakyimp wrote:

        The idea of acquiring all the source and compiling it meself sounds like days of effort.

        Not really... takes around 30 seconds to get all of the source (Google "php download", "mysql download", "phpmyadmin download", etc.) and then you just follow the instructions each package provides. Most likely, it'll simply be:

        ./configure [options that you might want to change/enable here]
        make
        make install

        and that's it.

          bradgrafelman;10958126 wrote:

          What do you mean you "renamed" the file? It obviously needs to use that file to get the correct values, so I'm not sure how taking away that file altogether is supposed to help? :p

          I renamed it to php-configOLD and copied the php-config file from the MAMP php5.3 dir to /usr/bin/php-config

          bradgrafelman;10958126 wrote:

          Have you tried simply downloading the source and compiling it manually?

          Yes, and it fails. The output has many warnings and errors but ends something like this:

          /Users/christopherwalsh/src/amfext-0.9.2/amf.c:3665: error: 'SUCCESS' undeclared (first use in this function)
          /Users/christopherwalsh/src/amfext-0.9.2/amf.c:3665: warning: comparison between pointer and integer
          /Users/christopherwalsh/src/amfext-0.9.2/amf.c:3667: error: 'IS_STRING' undeclared (first use in this function)
          /Users/christopherwalsh/src/amfext-0.9.2/amf.c:3667: warning: comparison between pointer and integer
          /Users/christopherwalsh/src/amfext-0.9.2/amf.c:3677: warning: return from incompatible pointer type
          make: *** [amf.lo] Error 1
          
          bradgrafelman;10958126 wrote:

          Not really... takes around 30 seconds to get all of the source (Google "php download", "mysql download", "phpmyadmin download", etc.)

          I wonder would this get me all the various libraries (i.e., sockets, mycrypt, mysql, etc) ? I should probably install apache first, then mysql, then php, no?

          Really not looking forward to this

            sneakyimp wrote:

            Yes, and it fails. The output has many warnings and errors but ends something like this:

            Does the 'phpize' command run successfully?

            Also, can you attach the config.log file in the amfext-0.9.2 (or whatever you renamed it to) directory? This should be a non-empty log file containing all of the output from the "./configure" command.

            EDIT:

            sneakyimp wrote:

            I wonder would this get me all the various libraries (i.e., sockets, mycrypt, mysql, etc) ?

            Careful now... are you talking about PHP extensions or the actual supporting libraries (think: .dll files on Windows) that your system would need?

            The answer to that last bit is no, if you don't have the necessary dependencies then the "./configure" command will (hopefully) fail (and you can hopefully deduce why by examining the last few lines of output), at which point you get to play the *nix-equivalent of Windows' "DLL Hell" of downloading the appropriate library, compiling, and then installing it before continuing the compilation of whatever software failed.

            Maybe I'm just a masochist, but I don't really find the whole process to be that bad.

              Well I got apache compiled and installed.

              I'm trying to compile php with this:

              sudo ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --enable-exif --enable-ftp --enable-mbstring --with-mysqli --with-pdo-mysql --with-pgsql --enable-soap --enable-sockets --enable-wddx --with-xmlrpc --enable-zip --with-openssl --with-curl --with-gd --with-mcrypt

              It fails with a complaint:

              If configure fails try --with-jpeg-dir=<DIR>
              configure: error: libpng.(a|so) not found.
              

              Not sure which library I need to compile which dll or where the dll should end up. This is the rather dll-hellish aspect i was not looking forward to.

                I have attached the config.log from the amfext directory.

                  sneakyimp wrote:

                  Not sure which library I need to compile

                  It's in the name: libpng. 🙂

                  EDIT: Well the config.log looks fine... I'd have to do some testing on a Mac itself, and I don't have a Mac VM anymore. I did note that on the AMFEXT homepage, there's no mention of a successful build on Mac, so perhaps it hasn't been made compatible with Mac yet?

                    I previously had amfext installed before I had to change up my MAMP/Apache/PHP install for some reason which now escapes me.

                    I've gotten thru libpjeg, libpng, and libmcrypt and now I'm halted with this error:

                    checking for specified location of the MySQL UNIX socket... no
                    configure: error: Cannot find MySQL header files under yes.
                    Note that the MySQL client library is not bundled anymore!
                    

                    Which looks partly like a library complaint and partly about a configuration file or something. Thoughts?

                      Sounds like you need to tell it where MySQL is, e.g. --with-mysql=/path/to/mysql

                        I installed MySQL using the DMG package from mysql website. It appears to work:

                        My-Mac:php-5.3.2 sneakyimp$ /usr/local/mysql/bin/mysql
                        Welcome to the MySQL monitor.  Commands end with ; or \g.
                        Your MySQL connection id is 16
                        Server version: 5.1.48 MySQL Community Server (GPL)
                        
                        Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
                        This software comes with ABSOLUTELY NO WARRANTY. This is free software,
                        and you are welcome to modify and redistribute it under the GPL v2 license
                        
                        Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
                        
                        mysql>

                        And I've tried to modify my configure command to specify the location of the mysql dir (/usr/local/mysql) but no luck. I get error when trying to configure. Here's my configure command:

                        sudo ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql/ --enable-exif --enable-ftp --enable-mbstring --with-mysqli --with-pdo-mysql --with-pgsql --enable-soap --enable-sockets --enable-wddx --with-xmlrpc --enable-zip --with-openssl --with-curl --with-gd --with-mcrypt --with-jpeg-dir=/usr/local/lib

                        here's the error:

                        checking for MySQL support... yes
                        checking for specified location of the MySQL UNIX socket... no
                        checking for mysql_close in -lmysqlclient... no
                        checking for mysql_error in -lmysqlclient... no
                        configure: error: mysql configure failed. Please check config.log for more information.
                        

                        EDIT: Inspired by this thread, I've tried a variety of paths for --with-mysql including /usr/, /usr/local, etc. but none seem to work.

                          GOODNESS.

                          OK so I tried this way and that with my config statement. I found that removing db-related stuff let it run to completion. I also found this bug report which indicated that the php compile doesn't seem to work on Max OSX if you have 64-bit MySQL installed.

                          So thanks to these instructions, I was able to remove 64-bit MySQL completely by entering these commands:

                              * Use mysqldump to backup your databases to text files!
                              * Stop the database server
                              * sudo rm /usr/local/mysql
                              * sudo rm -rf /usr/local/mysql*
                              * sudo rm -rf /Library/StartupItems/MySQLCOM
                              * sudo rm -rf /Library/PreferencePanes/My*
                              * edit /etc/hostconfig and remove the line MYSQLCOM=-YES-
                              * sudo rm -rf ~/Library/PreferencePanes/My*
                              * sudo rm -rf /Library/Receipts/mysql*
                              * sudo rm -rf /Library/Receipts/MySQL*
                          

                          Once I had removed 64-bit mysql, I downloaded the 32-bit MySQL DMG from the mysql site and install that.

                          I then ran this configure in the folder where I had extracted the php5.3.2 source:

                          sudo ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --enable-exif --enable-ftp --enable-mbstring --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-mysql=/usr/local/mysql --enable-soap --enable-sockets --enable-wddx --with-xmlrpc --enable-zip --with-openssl --with-curl --with-gd --with-mcrypt --with-jpeg-dir=/usr/local/lib

                          and it ran to completion! FINALLY.

                          then it was:

                          make
                          make install
                          

                          These also ran to completion and apparently I've managed to get mysql, mysqli, and pdo-mysql installed:

                          My-Mac:php-5.3.2 sneakyimp$ /usr/local/bin/php -r 'print_r(get_loaded_extensions());'
                          Array
                          (
                              [0] => Core
                              [1] => date
                              [2] => ereg
                              [3] => libxml
                              [4] => openssl
                              [5] => pcre
                              [6] => sqlite3
                              [7] => ctype
                              [8] => curl
                              [9] => dom
                              [10] => hash
                              [11] => fileinfo
                              [12] => filter
                              [13] => ftp
                              [14] => gd
                              [15] => session
                              [16] => iconv
                              [17] => json
                              [18] => mbstring
                              [19] => mcrypt
                              [20] => mysql
                              [21] => SPL
                              [22] => mysqli
                              [23] => PDO
                              [24] => pdo_mysql
                              [25] => pdo_sqlite
                              [26] => standard
                              [27] => posix
                              [28] => Reflection
                              [29] => Phar
                              [30] => SimpleXML
                              [31] => soap
                              [32] => sockets
                              [33] => SQLite
                              [34] => exif
                              [35] => tokenizer
                              [36] => wddx
                              [37] => xml
                              [38] => xmlreader
                              [39] => xmlrpc
                              [40] => xmlwriter
                              [41] => zip
                          )
                          

                          NOW. I just need to see if I can get amfext installed.

                            DAMMIT. I located my instructions from before about how to install and they aren't working. I'm not certain, but it may have something to do with the phpize command referring to some invisible preference file or configuration file that's still hanging around.

                            I've tried two different kinds of pecl install. Note that I reference the full path name to my newly installed instance of pecl:

                            /usr/local/bin/pecl i amfext-0.9.2

                            It ends up failing with an error:
                            make: *** [amf.lo] Error 1

                            I've attached the output text. I got pretty much identical results with this command:

                            /usr/local/bin/pecl install amfext-0.9.2

                            I also tried manually compiling it myself -- both as a separate .SO and as part of php. Compiling a separate .so file files. I've attached another txt file with more detail on that failure. The bottom line is the same failure:

                            make: *** [amf.lo] Error 1

                              So I have started to look at the source code of this extension to see what the problem might be. I'm not entirely sure what the configure script does (it is quite lengthy) but it appears to generate a Makefile based in PECL and PEAR settings. As far as I can tell, this makefile adds include directories which appear to complain all the necessary header files so it doesn't look like a missing header problem.

                              What puzzles me is that I was able to make this project just fine on a debian VPS recently. Perhaps there's something wrong with my PHP/PEAR/PECL settings? I tried to update them one by one.

                              My-Mac:~ sneakyimp$ pecl config-show
                              Configuration (channel pecl.php.net):
                              =====================================
                              Auto-discover new Channels     auto_discover    <not set>
                              Default Channel                default_channel  pecl.php.net
                              HTTP Proxy Server Address      http_proxy       <not set>
                              PEAR server [DEPRECATED]       master_server    pear.php.net
                              Default Channel Mirror         preferred_mirror pecl.php.net
                              Remote Configuration File      remote_config    <not set>
                              PEAR executables directory     bin_dir          /usr/local/bin
                              PEAR documentation directory   doc_dir          /usr/local/lib/php/doc
                              PHP extension directory        ext_dir          /usr/local/lib/php/extensions/no-debug-non-zts-20090626
                              PEAR directory                 php_dir          /usr/local/lib/php
                              PEAR Installer cache directory cache_dir        /private/tmp/pear/cache
                              PEAR configuration file        cfg_dir          /usr/local/lib/php/cfg
                              directory
                              PEAR data directory            data_dir         /usr/local/lib/php/data
                              PEAR Installer download        download_dir     /private/tmp/pear/download
                              directory
                              PHP CLI/CGI binary             php_bin          /usr/local/bin/php
                              php.ini location               php_ini          <not set>
                              --program-prefix passed to     php_prefix       <not set>
                              PHP's ./configure
                              --program-suffix passed to     php_suffix       <not set>
                              PHP's ./configure
                              PEAR Installer temp directory  temp_dir         /private/tmp/pear/temp
                              PEAR test directory            test_dir         /usr/local/lib/php/test
                              PEAR www files directory       www_dir          /usr/local/lib/php/htdocs
                              Cache TimeToLive               cache_ttl        3600
                              Preferred Package State        preferred_state  stable
                              Unix file mask                 umask            22
                              Debug Log Level                verbose          1
                              PEAR password (for             password         <not set>
                              maintainers)
                              Signature Handling Program     sig_bin          /usr/local/bin/gpg
                              Signature Key Directory        sig_keydir       /usr/local/etc/pearkeys
                              Signature Key Id               sig_keyid        <not set>
                              Package Signature Type         sig_type         gpg
                              PEAR username (for             username         <not set>
                              maintainers)
                              User Configuration File        Filename         /Users/sneakyimp/.pearrc
                              System Configuration File      Filename         /usr/local/etc/pear.conf
                              

                              Any thoughts on what the problem could be here are so very welcome. AMFEXT is apparently looking for a new project maintainer and I'd really like to understand what's going on here. I'm thinking about maybe trying to become the maintainer myself.

                                I can't believe it hadn't occurred to me to check if something changed in PHP. I googled for +amfext +php 5.3 and the second link was to a PECL bug which recommends two tiny code changes in the amfext source code:

                                edit amf.c
                                
                                On line 1188, replace:
                                int deallocResult = (*struc)->refcount;
                                
                                with
                                int deallocResult = Z_REFCOUNT_PP(struc);
                                
                                On line 2674, replace:
                                newval->refcount--;
                                
                                with
                                Z_DELREF_P(newval);
                                

                                I made these two changes and was able to phpize/configure/make/make install successfully. The "make install" copied the result to the correct directory /usr/local/lib/php/extensions/no-debug-non-zts-20090626/

                                I then edited my php.ini file at nano /usr/local/lib/php.ini and made sure it contained this line:

                                extension=amf.so

                                Then I was able to verify that the extension is one of the loaded extensions:

                                My-Mac:/ sneakyimp$ php -r 'print_r(get_loaded_extensions());' | grep amf
                                    [42] => amf
                                
                                  3 months later

                                  Although you might successfully compile using the solution given by sneakyimp. You might still encounter problems during runtime when using AMFPHP with AMFEXT. If you are still getting error using AMFPHP browser.

                                  Then,
                                  Check your apache logs for the errors. If the log contains the following line:
                                  ‘Symbol not found: _ZVAL_ADDREF’
                                  or
                                  ‘undefined symbol: ZVAL_ADDREF’.

                                  After making above changes to amf.c, You also need to replace ZVAL_ADDREF with Z_ADDREF_P to solve the problem.

                                  For complete detailed steps for installing AMFEXT with AMFPHP.
                                  http://www.peacemax.com/98/programming/php/install-amfphp-along-with-amfext-macphp-5-3-or-higher/

                                    18 days later

                                    The Php is great!
                                    What do you mean you "renamed" the file? It obviously needs to use that file to get the correct values, so I'm not sure how taking away that file altogether is supposed to help?

                                    Have you tried simply downloading the source and compiling it manually? Just go here, download the latest version, extract it somewhere, and run these commands in that directory:

                                      Write a Reply...