PHP 中的 Objective-C / Cocoa 桥?

发布于 2024-10-31 18:33:04 字数 221 浏览 1 评论 0原文

PHP 有什么好的 Objective-C 或 Cocoa Bridge/Connector 吗?我对 Mac 开发感兴趣,但想用 PHP 来完成。如果您能为我推荐任何适用于 Mac 的 PHP 编译器,那就太好了。

注意:我已经知道 Titanium 之类的应用程序,但这不是我想要的。 谢谢。

Is there any good Objective-C or Cocoa Bridge/Connector for PHP? I'm interested in Mac development, but want to do it with PHP. It'd be also good if you could recommend me any PHP compiler for Mac.

Note: I already know Titanium-like apps, and that's not what I want.
Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

故事和酒 2024-11-07 18:33:04

看起来这里有一个: http://www .slideshare.net/wezfurlong/hot-chocolate-you-got-cocoa-in-my-php

(下载链接在幻灯片中)

PHP 中几乎没有什么可以为您的 Mac 开发带来任何好处,尽管。如果您想使用具有更熟悉的语法的语言进行 Mac 开发,并且不想处理太多内存问题等,那么使用 MacRuby 或 RubyCocoa 进行编码应该不会比以前有太大的跳跃PHP 经验。

Looks like there's one here: http://www.slideshare.net/wezfurlong/hot-chocolate-you-got-cocoa-in-my-php

(download link is in the slides)

There's little in PHP that is going to do you any favors with Mac development, though. If you want to do Mac development with a language that has a more familiar syntax and you don't want to deal as much with memory issues and such, doing your coding with MacRuby or RubyCocoa shouldn't be too much of a jump from previous PHP experience.

余罪 2024-11-07 18:33:04

不幸的是我无法让 wezfurlong-Bridge 在 Mac OS X Lion 下运行。因此,我决定利用 Objective-C 的灵活性让 PHP 与我的 Cocoa 应用程序对话,甚至创建对象并向它们发送带有参数的消息。
您可以在 http://github.com/cundd/pop/ 上获取包括(非常基本的)示例应用程序的源代码

Unfortunately I wasn't able to get the wezfurlong-Bridge running under Mac OS X Lion. So I decided to use the flexibility of Objective-C to let PHP talk to my Cocoa application, even create objects and send messages with arguments to them.
You can get the source including the (very basic) sample application on http://github.com/cundd/pop/

心房的律动 2024-11-07 18:33:04

我像这样“桥接”PHP…简单就是金…如果你想变得更奇特,JSON 来回编码,并将原始数据作为 base64 编码字符串发送…

- (NSString *)getSomethingFromPHP {
    NSString *scriptPath = [[[NSBundle mainBundle]resourcePath]
        stringByAppendingPathComponent:@"myPHPscript.php"];
    NSString *standardIn = [myApp someData]
    NSTask *php  = [NSTask new];
    NSPipe *pipe = [NSPipe new]; 
    [php setLaunchPath:@"/usr/bin/php"];
    [php setArguments:[NSArray arrayWithObjects:
       @"-f", scriptPath, standardIn, nil]];
    [php setStandardOutput:pipe];       
    NSFileHandle *handle = [pipe fileHandleForReading];
    [php launch];
    NSString *string = [[NSString alloc] initWithData:
       [handle readDataToEndOfFile] encoding:NSASCIIStringEncoding]; 
    return string;
}

I "bridge" PHP like this… simplicity is golden.. If you wanna get fancy, JSON encode things back and forth, and send raw data as base64 encoded strings…

- (NSString *)getSomethingFromPHP {
    NSString *scriptPath = [[[NSBundle mainBundle]resourcePath]
        stringByAppendingPathComponent:@"myPHPscript.php"];
    NSString *standardIn = [myApp someData]
    NSTask *php  = [NSTask new];
    NSPipe *pipe = [NSPipe new]; 
    [php setLaunchPath:@"/usr/bin/php"];
    [php setArguments:[NSArray arrayWithObjects:
       @"-f", scriptPath, standardIn, nil]];
    [php setStandardOutput:pipe];       
    NSFileHandle *handle = [pipe fileHandleForReading];
    [php launch];
    NSString *string = [[NSString alloc] initWithData:
       [handle readDataToEndOfFile] encoding:NSASCIIStringEncoding]; 
    return string;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文