Wez Furlong I am Wez Furlong, Chief Software Architect at Message Systems. We're responsible for building an awesome Messaging Platform.

I'm also a PHP Core developer and OpenSource contributor, residing in Maryland, USA with Juliette, Xander and Lily. (read more)

Subscribe. (circulation 957)
Comments. (circulation 8)

Search powered by Google

PHP Objective-C Bridge

4th November 2007 @ 12:34 EDT
updated 4th November 2007 @ 12:35 EDT

I've had some code hanging around on my laptop for the better part of a year (feels like two, but I don't think I've had my MBP that long), that implements a bridge between PHP and the Objective-C runtime. This is similar in spirit to CamelBones and PyObjC, but obviously a bit less mature.

Yesterday I debugged the last portion that I regarded as a total showstopper for anyone else that might want to use it, and added a script that pulls in your PHP installation and dependent libraries (such as Fink or Mac Ports libraries) and generates a "Bundle" and optionally a DMG containing the Bundle. I also persuaded Jan to try it out on Leopard, and discovered that Apple has deprecated most of the things I've been using for this (doh!) but we got it working on Leopard too. (note: you'll need to build your own PHP on Leopard, the one Apple ships has had its exports stripped, so you can't run the extension--it'll build, but not run)

There's still some way to go before I consider this "nice" to use, but it's a solid start. Jan built a simple GUI for the ping command:

I want to underscore that this is still in the very early stages, and that you'll most likely need a good bit of C and Objective-C savvy to get the most out of it right now, and that neither Jan nor myself can guarantee to fix problems that arise, but I in the spirit of release early, release often, I've put the code into the PHP CVS repository in the php-objc module, and created a php-objc mailing list on the PHP list server.

So, if you can figure out how to get at the code and on the mailing list, welcome! If you can't, it's too early for you to participate; you'll need to hold tight until we've made things easier to use.

Post a comment

Excellent!

4th November 2007 @ 14:30 EDT

Hey Wes-

This is great news... I am very excited about this project of yours...

I am a big Cocoa fan and have written a PHP framework roughly based on the Cocoa architecture called PHOCOA (http://phocoa.com). I have been waiting for this project for a long time!

I have written a Mac OS X app called "PHOCOA Builder" that is the analog of Interface Builder. Right now though I have to use some cheap tricks to share data across the 2 platforms. There's lots of metadata in the PHP side that would be *great* if only I could access it from the Cocoa side. Right now I just have some PHP scripts that dump things out in XML and then the Mac app reads them, but this will be much cleaner.

I will definitely be giving this a try sometime soon.

Thanks!

by Alan Pinstein in .

Nifty

4th November 2007 @ 20:18 EDT

Looks nifty, I was starting to get jealous of the Python and Ruby guys since they have this built-in to Leopard now :-)

Speaking of Leopard goodies, you mentioned a couple years ago working on a DTrace extension for PHP. Have you tried it on 5.2.4 on Leopard yet? If it does work, how would we use it in conjunction with the "Instruments" GUI that Apple developed?

Thanks,

by Josh K. in .

I haven't tried Leopard yet

4th November 2007 @ 20:46 EDT

I'm planning to upgrade this week, and I do have plans to make the dtrace extension work on Leopard as well as Solaris. I also have some plans to make it part of the core distribution of PHP too, but that depends on having enough energy to get it in there.

Leopard's Scripting Bridge

5th November 2007 @ 10:08 EDT

Since you've been working with this since Tiger, I take it this is (at this point) unrelated to Leopard's officially introduced Scripting Bridge?

by Tim Stiles in .

BridgeSupport

5th November 2007 @ 13:12 EDT

I found the BridgeSupport pieces last night, and I've started to integrate them into php-objc; it certainly makes things much easier!

Awesome

5th November 2007 @ 16:37 EDT

This is great to see. I have been wanting to learn Obj-C and I know a good portion. The parts I do not know are the frameworks. That is still to come.

It is great to see a bridge between the 2 like this. It will make things much easier for people to work with OS X.

Good work and I hope to see more in the future :)

by http://josephcrawford.com in .

DTrace

12th December 2007 @ 09:50 EDT

Did you get to update DTrace for MacOS-X? I just checked cvs — files are marked as 2 year old :-/

Mac PHP Build Help

31st January 2008 @ 11:38 EDT

Is there any way I could convince you to post instructions on getting PHP to build on Leopard, preferably with extensions like PDO, mcrypt, mhash, etc? I'm new to Mac and new to compiling PHP so despite several hours of trying, I have yet to get a successful build on Mac that has the extensions I need.

Thanks a bunch in advance.

by David Stockton in .

Nevermind on the build instructions

11th April 2008 @ 00:37 EDT

This <a href="http://blog.phpdoc.info/archives/83-php-5.2.5-on-Leopard.html">page</a> got me to nearly what I needed.

I got your extension compiled and installed, but alas I am not yet familiar enough with xcode to figure out how to get the option to create a Cocoa-PHP app or even how to get the sample code into a project correctly where I can see the currency converter actually do something.

Are you still actively working on the bridge code at all?

by otkcotsd@yahoo.com in .

Development is still in-progress

11th April 2008 @ 08:53 EDT

There's a mailing list you can join if you're super-interested (php-objc@lists.php.net), or you can just browse around the archives at <a href="http://news.php.net/php.objc">http://news.php.net/php.objc</a>.

You should note that xcode doesn't help you write a php based cocoa app. I believe that it is possible to set up a project template to make that easier, but afaics there is no officially supported way to do that either... and it looks to be highly xcode version specific.

You can however use interface builder to create nib files independently from xcode.

Building and running PHP extensions works now

17th December 2008 @ 08:40 EDT

You wrote:

<blockquote>you'll need to build your own PHP on Leopard, the one Apple ships has had its exports stripped, so you can't run the extension--it'll build, but not run<blockquote>

I finally managed to build the soap.so for the stock MacOSX Leopard PHP installation: <a href="http://www.entropy.ch/phpbb2/viewtopic.php?p=12785#12785">http://www.entropy.ch/phpbb2/viewtopic.php?p=12785#12785</a>.

I got the tip from the <a href="http://lists.apple.com/archives/macos-x-server/2007/Nov/msg00304.html">macos-x-server list</a>.

by Henrik in .
Post a comment

Would you like to work with me?
I have positions open for server/infrastructure software development (C) and QA.

Ohloh profile for wez