1

I'm pretty new to Swift and I'm trying to create an GUI application that parses PHP code and return the output (for study purpose).

In other words, what I'm trying to ask is: how to reach PHP from Swift? I have a snippet and I want to get the resulting output, but I'm inside an OSX application.

My first idea was to "bundle" PHP in my app, but I really don't have a clue on how (or even if it's possible) to do that.

I'm also thinking on taking the code and sending it to the shell and just wait for the response.

Well, any thoughts?

Thank you very much!

Rafa Jaques
  • 115
  • 7
  • This is too generic of a question. SO should be used to ask questions when you have initially written something and found a stumbling block. Not ask how to do an entire project. On the flip side, you can't bundle PHP in an app. If you thinking sending the code to a server and waiting for a response is something you can do, try it out since you are doing things for study purposes. Once you find a blocker ask a new question! – John Riselvato Dec 14 '15 at 18:46
  • You want to interpret PHP code in Swift? Why? Just run PHP on a server and HTTP? – Arbitur Dec 14 '15 at 18:46
  • Actually this is a very small project. Just a text editor that runs the PHP code, so the question is kind of "the full project" because there is no other stuff to do within it. – Rafa Jaques Dec 14 '15 at 18:47
  • I want to run because I'm trying to develop an app for OSX to get a PHP snippet and show the resulting output without opening the terminal. – Rafa Jaques Dec 14 '15 at 18:49
  • http://stackoverflow.com/questions/10866301/execute-php-code-in-a-string This might be of use for you – Arbitur Dec 14 '15 at 18:50
  • That's within PHP. I need to reach PHP from Swift. – Rafa Jaques Dec 14 '15 at 18:51
  • You can send the string you wrote in Swift program to webserver that then executes your string and returns the outcome. – Arbitur Dec 14 '15 at 18:52
  • Since it's an offline app, there is no webserver. Based on your suggestions, I think that the better way is to send the code to the shell and wait for the output. – Rafa Jaques Dec 14 '15 at 18:54

0 Answers0