php / mySQL in Dashcode?

Discussion in 'iOS Programming' started by jarv, Jan 20, 2011.

  1. jarv macrumors newbie

    Jan 17, 2011
    Hi, is there a way of using php / mySQL in Dashcode?
  2. ulbador macrumors 68000


    Feb 11, 2010
  3. jarv thread starter macrumors newbie

    Jan 17, 2011

    So for web service, do I just add PHP page in my project and can I still add Library objects/parts etc within Dashcode?

    what do you mean by directly?
  4. ulbador macrumors 68000


    Feb 11, 2010
    You are not going to be able to put PHP in your project. What you can do is build a PHP page on a remote server and have the Dashcode connect it it via Ajax.
  5. t9b, Jan 20, 2011
    Last edited: Jan 20, 2011

    t9b macrumors newbie

    Jan 20, 2011
    Dashcode PHP and MySQL


    First things first. I've come to see Dashcode as a kind of rendering engine for web stuff but it's got much more than that in it. You can get it to serve php, the only problem being that you cannot directly preview the result of a php page being served in the editing mode. Most people get confused about that bit. It's 2 different things.

    Happily you can test php in the built-in browser that launches when you build and run. You can of course edit the php code in the edit mode, but the preview just shows the un-served raw code.

    To make it work, make sure that you have got php and MySQL running on your machine. I'm assuming you know how to do this?

    The apache server does not need to be running, but it helps if you are going to be test publishing dashcode using your users Sites folder or if you have saved a php file there.

    That being said you don't need to publish your site to test it in the built-in browser as long as php and MySQL are running on your machine.

    Add your php file to your dashcode project and then build and run the project.
    Your simulation browser will launch and hey presto the PHP file gets served when you call it just as if it had been served as one of the other commentators put it.

    One word of warning - don't go around changing the .html to .php on files generated by dashcode, because that just breaks it. only use .php on files that you create / import.

    Interestingly what I was doing was creating a php file to select a MySQL table and return a JSON result set to be used in a datasource. I found that I could just upload the necessary php files to a folder in my dashcode project and point the datasource to the path that would find them. That's the Web service bit, but I also had a web page that was also needed and this too worked in the browser simulator.
  6. carlosbutler macrumors 6502a


    Feb 24, 2008
    London City
    Why do you not just start the web server that is already installed on every mac? That can run as a PHP server if you want, and you can then edit your php in whatever you want.

    In terms of the SQL databases, you can download an addon for Apache I think that allows you to run your mac as a database machine as well. And when you upload your code, as long as your database and php are on the same server you will not need to change anything as it still referenced through localhost.

    Here is a link to start the PHP server:
  7. jarv thread starter macrumors newbie

    Jan 17, 2011
    thanks for all your help, I have a PHP website setup already, I have been reading about HttpRequest Ajax too,

    so I can add a PHP page to my Dashcode project linked to my live site?

  8. jarv thread starter macrumors newbie

    Jan 17, 2011
    I just added a PHP page to my project with <? echo 'hello'; ?> and navigated to it, nothing happened?! hmm well, it turned out blank!

Share This Page