<?php
 
if (! isset($argv[1])) {
    echo "enter a search term:\n";
    echo 'php ' . __FILE__ . " <search_term>\n";
    exit;
}
 
$term = urlencode($argv[1]);
$url = "http://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStoreServices.woa/wa/wsSearch?limit=10&entity=software&term=$term";
$json = file_get_contents($url);
 
print_r(json_decode($json, true));
 
?>

More info here.

  • Digg
  • del.icio.us
  • Facebook
  • Reddit
  • Twitter
Tagged: , ,

I just emailed Joe the steps I’ve used to get PHP, MySQL, Memcached and Apache working on my OS X machine. He’s the 3rd person in 2 days who’s ask me about how i setup PHP on my Mac so I figured other people would be interested too. So I elaborated upon the steps I sent to Joe in order to post em here for public consumption… hopefully this’ll help a few folks out.

There’s a bunch of solutions to get this stuff set up with a quick double click or a few commands in your terminal but I like things to be “my way”. So, if you’re interested read on.

The Easier Stuff

The first thing is to install MacPorts. This makes things quite a bit easier. Also, Mysql comes pre-packaged & I don’t bother compiling it myself. So grab that over here & install that too.

Recompiling Apache

I’ve found it necessary to recompile Apache as 32 bit only. Some PHP extensions didn’t like having a 64bit Apache around. This has been my experience so your mileage may vary. Anywho download Apache and unzip it somewhere. Personally I keep src in ~/Dev/open-src.

Shut down your stock install of Apache in System Preferences -> Sharing -> Web. Next, fire up your terminal and cd into the unzipped source folder. When you’re in the terminal run the following:

$ CFLAGS="-arch i386"
$ ./configure --enable-layout=Darwin --enable-mods-shared=all
$ make
$ sudo make install

This should only take a couple minutes & has always gone smoothly for me. Now let’s restart Apache and see if it works:

$ sudo apachectl restart

Hopefully you don’t have any errors show up:

  1. Cruise by http://localhost to make sure stuff shows up
  2. run sudo apachectl stop and make sure nothing shows up at http://localhost (server is “off”)
  3. run sudo apachectl start and make sure http://localhost is back up

If you get an error about apr or apr-util:

  1. take /opt/local out of your PATH (export PATH=<whatever it is now minus /opt/local)
  2. cd back to the Apache source
  3. make clean
  4. make
  5. sudo make install

Compiling PHP

Download the PHP source over at http://www.php.net/downloads.php, toss it next to the Apache source, unzip the tar (I guess “untar” is more appropriate) and finally cd into the source folder.

Now open another terminal window cuz you’re going to need to install some stuff via MacPorts as well. What you need from MacPorts depends on what you wanna build into PHP. Usually I enable stuff like GD, MySQLi, freetype, pdo etc. This is my config. and you may want more stuff & I’ll try n help w/ that in a bit.

Here’s all the shit I have installed via Macports:

arin@Halloween.local:~  > port installed
The following ports are currently installed:
 apr @1.3.3_0 (active)
 apr-util @1.3.4_0 (active)
 apr-util @1.3.4_1
 autoconf @2.62_0 (active)
 automake @1.10.1_0 (active)
 bzip2 @1.0.5_1 (active)
 cclient @2007_0 (active)
 cyrus-sasl2 @2.1.21_0+kerberos (active)
 db46 @4.6.21_1 (active)
 expat @2.0.1_0 (active)
 fontconfig @2.6.0_0+macosx (active)
 freetype @2.3.7_1 (active)
 gettext @0.17_3 (active)
 gperf @3.0.3_0 (active)
 help2man @1.36.4_1 (active)
 ImageMagick @6.4.7-2_0+q16 (active)
 jpeg @6b_3 (active)
 libevent @1.4.8_0 (active)
 libiconv @1.12_0 (active)
 libpng @1.2.32_0 (active)
 libtool @1.5.26_0 (active)
 libxml2 @2.7.2_1+darwin_9 (active)
 m4 @1.4.11_0 (active)
 memcached @1.2.6_0 (active)
 ncurses @5.6_0 (active)
 ncursesw @5.6_1 (active)
 neon @0.28.3_0 (active)
 openssl @0.9.8i_0 (active)
 p5-locale-gettext @1.05_0 (active)
 perl5.8 @5.8.8_3+darwin_9 (active)
 pkgconfig @0.23_1 (active)
 readline @5.2.012_1 (active)
 serf @0.2.0_0 (active)
 sqlite3 @3.6.4_0 (active)
 subversion @1.5.3_0 (active)
 tiff @3.8.2_2+darwin_9+macosx (active)
 zlib @1.2.3_1 (active)

You probably don’t need some of this at all, ever, but I listed them all just in case. I’d recommend you start with:

  • bzip2
  • expat
  • fontconfig
  • freetype
  • gettext
  • gperf
  • ImageMagick
  • jpeg
  • libevent
  • libiconv
  • libpng
  • libtool
  • libxml2
  • memcached
  • openssl
  • sqlite3
  • tiff
  • zlib

So for each of those:

$ sudo /opt/local/bin/port install <INSERT_PORT_NAME_HERE>

After all that’s done it’s time to compile PHP itself. I put PHP in /usr/local/php<version>. So for PHP 5.2.8 I install it to /usr/local/php5.2.8. You’ll see this is a few of the .configure options below. You’ll also see that I enable an ini directory and also designate that same dir as the location for the main php.ini. This is how I like it… adjust as you please. So cd to the un-tar‘ed PHP source folder and run the following commands:

$ ./configure \
  --with-apxs2=/usr/sbin/apxs \
  --prefix=/usr/local/php5.2.8 \
  --with-config-file-scan-dir=/usr/local/php5.2.8/php.d \
  --with-config-file-path=/usr/local/php5.2.8/php.d \
  --disable-posix \
  --enable-cli \
  --with-mysql=/usr/local/mysql \
  --with-mysqli=/usr/local/mysql/bin/mysql_config \
  --with-jpeg-dir=/opt/local/include \
  --with-png-dir=/opt/local/include \
  --enable-gd-native-ttf \
  --with-freetype-dir=/usr/local/php5.2.8 \
  --with-zlib \
  --enable-pdo \
  --with-pdo-sqlite \
  --with-sqlite=shared \
  --enable-sqlite-utf8 \
  --with-pdo-mysql=shared,/usr/local/mysql \
  --with-xsl \
  --enable-soap \
  --enable-mbstring \
  --with-zlib-dir=/usr \
  --with-ldap \
  --with-xmlrpc \
  --with-iconv-dir=/usr \
  --with-libxml-dir=shared,/usr/local/php5.2.8 \
  --with-curl \
  --with-gd \
  --enable-gd-native-ttf \
  --with-jpeg-dir=/usr/local/lib \
  --with-png-dir=/usr/X11R6 \
  --with-freetype-dir=/usr/X11R6 \
  --with-xpm-dir=/usr/X11R6 \
  --enable-sockets \
  --with-pear=/usr/local/php5.2.8/

$ make
$ sudo make install

…And hopefully that works out for you ;)

Tourbleshooting… No, It’s Not Science

OK – so if you run into problems during ./configure you’re going to have to carefully look at the message and see what’s missing. For example: if it’s bitching about sqlite then make sure you have installed it via MacPorts using the command /opt/local/bin/port installed. If you don’t see it there, install it. Then run .configure but tack on --with-sqlite=/opt/local/include. Again, if that doesn’t work try the same thing with --with-sqlite=shared… if that doesn’t work try it with --with-sqlite. It can get pretty annoying. The jist is that the compiler needs to know how to find the header files. MacPorts makes this stuff pretty easy cuz you wont have to compile xyz yourself… it just does it & tacking on xxxxx=/opt/local/include usually does the trick. Sometimes you might have to resort to copying the .h file from /opt/local/include to /usr/include. I’ve had it go smooth and I’ve had it be a bitch.

You can follow the above “tip” if you want to add stuff as well. Usually just give .configure the switch, watch it break, see what it wants, install it via MacPorts, add the switch back with xxx=/opt/local/include and move on to the next one. Like I said, it’s not science but you’ll eventually get it working.

PECL Extensions

These always go well for me. Here’s what I’ve got installed:

arin@Halloween.local:/usr/local  > which php
/usr/local/php5.2.6/bin//php
arin@Halloween.local:/usr/local  > php -m
[PHP Modules]
apc
ctype
curl
date
dom
filter
gd
gettext
hash
iconv
imagick
imap
json
ldap
libxml
mbstring
memcache
mysql
mysqli
pcre
PDO
pdo_mysql
pdo_sqlite
Reflection
session
SimpleXML
soap
sockets
SPL
standard
tokenizer
xdebug
xml
xmlreader
xmlrpc
xmlwriter
xsl
Zend Debugger
zlib

[Zend Modules]
Xdebug

Some of these are as a result of the PHP compilation but a bunch of them, especially APC, memcache & imagick, were installed via pecl.

You should have pecl installed in your PHP’s bin directory. In the example above the line --prefix=/usr/local/php5.2.8 means that that’s where this install of PHP is. So in there you’ll see a bin folder in there with php, pear & pecl. So, feel free to add /usr/local/php5.2.8 to your $PATH. Anyways… go nuts and install all the pecl extensions you want. If for some reason you don’t have pecl go to http://pear.php.net/go-pear for info on how to install pecl and pear.

Anywho… once that’s settled just go on and type in:

$ sudo pecl install memcache
$ sudo pecl install apc
$ sudo pecl install imagick

Memcached

Just install this via MacPorts… this one’s easy. Woot

You’re Done

Now that I typed all this shit out it does seem like a bit much but it’s really not that bad. Getting the flow of installing a port then modifying .configure was my “ah ha” moment. Once you “get” that you’ll eventually breeze through. Just make sure to keep notes. I’ve kept notes the first time I went thru this and it’s helped a ton. The first compile I did took me hours of fucking w/ this and tring that till I had my “ah ha” (aka “duh”) moment. I’ve gone thru this process 3 times since and every situation is different, but the notes I compiled the first time w/ my .configure options etc greatly reduced the time it took to do it again. It’s kind of like snowboarding… at about your third trip to the slopes you’ll be able to get down a run w/o falling :)

Good luck.

  • Digg
  • del.icio.us
  • Facebook
  • Reddit
  • Twitter
Tagged:
April 11th, 2008

Dear Santa

Hook me up yo….

MacBook pro

hmmm, its only April. FUCK!

  • Digg
  • del.icio.us
  • Facebook
  • Reddit
  • Twitter
Tagged: ,
January 23rd, 2008

Trim That Shit Apple!

I have my iPhone all setup etc (more on that some other time maybe) and just about everything is A-OK except one thing is fucking pissing me off. I’ve had this same issue with the Ipod/iTunes as well. This issue is string trimming…

Currently some contacts in my Contacts List on my iPhone are indented by 1 space. Now, i checked thru these entries on my Mac’s Address Book and none of these entries have a leading space character. None of them. But still, on the iPhone some contacts have this little indent going on. Kinda looks like this:


 Ryan Abcdefg
  Ryan Bcdefg
 Ryan Cdefg
  Sam Blabla

Why the fuck is this happening? I trolled around the web and found someone in the Apple Forums with the same problem. They insist that their Address Book doesn’t have any leading space characters for any of the offending entries. BTW, The forum thread has no proposed solutions.

Now, I stash my contacts in a few places and sync them all up to Plaxo. I’m using Address Book on both my work and home MacBooks, some contacts that are created on my phone and a bunch of others I sync to Plaxo from my Yahoo! account. And somehow, while setting up my iPhone, iTunes asked me if I’d like to import contacts from Yahoo! as well. So, that leaves a few points of fuck up failure here. I’m guessing one of these sync points left/inserted an “invisible” character in either the prefix, first name or last names fields that’s manifesting itself as an “indent”.

I’ve had a similar issue with iTunes and the iPod. I’ve seen multiple entries for the same artist… its always just been the same artist name with trailing whitespace. So “Bad Religion” vs. “Bad Religion ”. Here the solution is easy because your can edit the ID3 tags of multiple songs at once using iTunes. Now, this new iPhone issue of mine is not as easy to fix…

Last night I went thru almost all of my contacts and made sure that their first and last names did not have any leading spaces. After that i synced the iPhone to my machine and nada; the contacts on the iPhone still had the indenting BS going on. Funny enough, the list of contacts on the Mac itself did not have any of the whacky indenting going on – just on the phone.

This leaves me pretty confused. I’ve edited names on the iPhone itself to no avail. The edit screen for a contact shows no leading whitespace… regardless I cleared out a couple contacts’ names and reentered them and even this didn’t fix the issue.

I guess I’ll write a script to plow thru my Address Book database tonight and see if I can find any whacky data.

But, seriously… why doesn’t Apple just trim the fucking strings? Maybe the iPhone bullshit is a bit more complicated (assuming crazy characters are at fault) but the iTune thing is just lame; just trim the fucking string upon saving data.

Bleh, hopefully I’ll have this shit squared away tonight.

  • Digg
  • del.icio.us
  • Facebook
  • Reddit
  • Twitter
Tagged: , , ,
January 16th, 2008

Getting an iPhone in 6 Days

… well, technically I already have the iPhone. I got an iPod Touch for XMas, exchanged it, payed the balance and got an iPhone. The lil guy has been sitting in my desk drawer since 12/26. I’ve been patiently waiting for my Verizon account to expire… I only have 6 more days to wait :) .

I’ve been very concerned about switching to ATT from Verizon. As far as the service goes I have had zero issues with Verizon. I get great reception both at home, work and the few places I frequent. Can’t complain. But, I am pretty annoyed with Verizon’s phone selection as well as the fact that some of their cooler phones are crippled (no PC connection via Bluetooth on my current Blackberry etc). Also, I can’t deny that the sexiness of the iPhone is a huge factor. Being a Mac user I’m also stoked on the fact that I’ll be using a phone that doesn’t use hacky software to sync with my work & home machines.

Either way, I’m pretty stoked. The new software update that was shown at this week’s MacWorld is making me even more excited. There’s wasn’t anything too ridiculous but the additions are nice.

Some time next week I’ll outline (with screenshots) the switching/activation process as well as my pros ‘n cons/comparison/experience with going from a Blackberry to an iPhone.

Search This Blog