Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:69815 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 5095 invoked from network); 23 Oct 2013 19:04:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Oct 2013 19:04:32 -0000 Authentication-Results: pb1.pair.com header.from=mike@quasidea.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=mike@quasidea.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain quasidea.com from 209.85.220.46 cause and error) X-PHP-List-Original-Sender: mike@quasidea.com X-Host-Fingerprint: 209.85.220.46 mail-pa0-f46.google.com Received: from [209.85.220.46] ([209.85.220.46:49506] helo=mail-pa0-f46.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1B/56-10840-0CD18625 for ; Wed, 23 Oct 2013 15:04:32 -0400 Received: by mail-pa0-f46.google.com with SMTP id rd3so1034293pab.33 for ; Wed, 23 Oct 2013 12:04:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:content-type:message-id:mime-version :subject:date:references:to:in-reply-to; bh=pRAzvyZr5sXgGth7Epd4F9rTBfzuEgKozTqh+GxxI/Y=; b=adGHriA9LKuID97SV2WtBbS4+lwsXESoQx0vwuJHXEvvQVC4tVQ1cUg9+aHWBGsylE UBYUBoqP19SrDpCIlL7V6Usb84rEXLLg4KuY0ZKb2azD6OIMnGnAMEov7eTYY4MwFKLE eIb0Srp85LPTHJ76MhHNXmkZj1wYhP7aQ0ABQvuJwL0NTw4SvCzKvd2i2/8hiXVynhda KPsSfoOIiGZ/f1TVkn7BrBCqc8DyZQuahonMQY2altlAt6A9OW1WYcVUo42aH1NfVYNR rgMQqhewME/wBNshg88zQUYh0XcY2ueLM+sBzTlsmxxrQ4xtzT8herk1NDzC294tSA3A 2iuw== X-Gm-Message-State: ALoCoQl/OQ57hWPQoyUSLK5KhE9YswXFj5nB/CmxmIT05h+hUMxtwmuzO+4ZH0pQ2nhxREEGx7ct X-Received: by 10.66.175.133 with SMTP id ca5mr4947929pac.40.1382555068739; Wed, 23 Oct 2013 12:04:28 -0700 (PDT) Received: from [10.0.2.131] ([108.175.222.178]) by mx.google.com with ESMTPSA id yo2sm43112883pab.8.2013.10.23.12.04.26 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 23 Oct 2013 12:04:27 -0700 (PDT) Content-Type: multipart/alternative; boundary="Apple-Mail=_D2A66D82-0EE3-4650-9086-96E39B057B40" Message-ID: Mime-Version: 1.0 (Mac OS X Mail 6.6 \(1510\)) Date: Wed, 23 Oct 2013 12:04:25 -0700 References: <7AB4C690-44A7-4A93-9026-F5E735716E0F@googlemail.com> To: internals@lists.php.net In-Reply-To: <7AB4C690-44A7-4A93-9026-F5E735716E0F@googlemail.com> X-Mailer: Apple Mail (2.1510) Subject: Re: [PHP-DEV] PHP and Objective-C From: mike@quasidea.com (Mike Ho) --Apple-Mail=_D2A66D82-0EE3-4650-9086-96E39B057B40 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=windows-1252 Kevin, This may seem like a good idea =97 and it's been attempted several times = in the past=85 if you do a just google for PHP and Objective-C and/or = PHP and Cocoa, you'll see some hits for a number of past open source = project that attempted to start going down this path, but never really = got any traction. However, even if those projects did come to fruition, in practice this = actually won't help that much. At the end of the day, when writing applications in for Mac OS X and/or = iOS, a developer will need to learn two things: 1. the Objective-C language and runtime 2. the Cocoa or Cocoa Touch API As someone who has done a lot of PHP development and who transitioned = into iOS development several years ago (and now I am actively developing = on both platforms), I can say from personal experience that "#2" is = significantly more of a challenge than "#1". Ultimately, when looking at #1, it's really just a change in syntax. = You're really just using a bunch of "[]" and "." instead of "$" and = "->". Honestly, when comparing the language of Objective-C and PHP, = other than these syntax differences, there isn't much else that is = different. Even memory management is now taken care of you via the = runtime's ARC feature. And yes, while I may be oversimplifying things = here a bit, once you dig into it I think you'll quickly see what I mean. I actually gave a talk about this at php|tek last year: = http://www.quasidea.com/talks/iOSDevelopmentPrimerForPHP.pdf The steeper learning curve, by far, is #2, and unfortunately, you would = still have to learn it even if you were able to wrap all the API calls = around a PHP wrapper. It's ultimately the reason why there is so much push back against a lot = of these language-based wrappers around Cocoa and Cocoa touch, including = things like Mono Touch, Flash Builder, and even to a certain extent the = hybrid app platforms like PhoneGap or Appcelerator. Regardless of your = choice of language, you still need to learn the APIs. If you want some free advice from someone who has gone down the path of = transitioning from PHP to Objective-C, spend the time to learn = Objective-C and the Cocoa [Touch] APIs natively. It will be a much = wiser investment of your time and effort than trying to build a wrapper = library for it in PHP. Just my 2 cents, Mike On Oct 23, 2013, at 11:20 AM, Kevin Ingwersen = wrote: > Hello there. >=20 > I have absolutely no real clue where to post this but rather into some = sort of development mailing list. >=20 > Recently, I started to work on some tool that will compile a lot of = PHP scripts into a single file, and may even go further and bundle a PHP = binary within to create a sort-of standalone PHP executable. The concept = is quite simple, but the including stuff isn't really. But, as I was = thinking about this idea, I came across the various ideas of trying to = use a GUI with PHP scripts. On windows, that has already been possible. = But not on Mac - at least I found no working solution. wxWidgets (as = extension, wxPHP) won't compile because it relies on the Carbon = framework - which has been discontinued since about at least three major = releases. And the extension can't be made to work with Cocoa, as this is = Objective-C - and not C/C++. >=20 > And here is the keyword, Objective-C. >=20 > I have learned, that Objective-C is, like C++, a layer ontop of C. = Furthermore, I saw that there was am "embed" SAPI, yet I couldn't find = any way to fully integrate PHP into a binary that had non-Zend code = inside; there is only a book. And due to my visual impairment, I am = unable to read said book. >=20 > So I came up with a few questions: >=20 > - How could one integrate PHP into a C/C++ programm? > The reason I ask is because, I want to see how far I could integrate = PHP into an Objective-C program. >=20 > - When integrating, how could I expose Objective-C functions to = PHP's "C-Scope"? > The Zend 2 API is very poorly documented; basic things like = reading/writing to and from objects is documented so poorly, that I had = to read a ~100 page long slide share. But yet, I thought that the only = way to expose stuff like Objective-C functions, or even Classes, to PHP = would be to add a PHP-Extension-like structure, so that once the = Objective-C programm was initialized, it would use the Zend API to = expose things to PHP. >=20 >=20 > My goal is to enable access to at least the GUI functions of Cocoa, = which can be reached thru Objective-C. Using this method, I wanted to = create a new kind of framework, and combine it with my previous project = of pulling PHP files into one. I think it already made a clue in your = head if you are able to understand my - sadly - weird english. >=20 > Once I can expose Objective-C scope into PHP, I would be able to = enable GUI's with PHP. Since PHP is very easily understood, it could be = a good start for switchers - like me - to understand the other language = and API. Now, we can use my code-compiler idea and build all the PHP = script into one single, giant file - maybe even use Phar as this offers = a great solution for that. The last step is to combine the executable = and script, and we would get an actual and valid Mac OS X application - = we do not need the compiling part, but it'd be cool ;). >=20 >=20 > I hope anybody can help me, poke me into the right direction to = anything. This is just one idea I have, and something I hope to realize. = I taught myself a good amount of c++ by trying to create a wrapper of a = C++ class for a PHP extension. So I would try the trick again to learn = more about objective-C. >=20 > Kind regards, > Kevin Ingwersen >=20 > PS: I am from germany, my english may not be very understandable - so = please ask if you didn't understand something! :) > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >=20 --Apple-Mail=_D2A66D82-0EE3-4650-9086-96E39B057B40--