Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

jarv

macrumors newbie
Original poster
Jan 17, 2011
12
0
Hi, is there a way of using php / mySQL in Dashcode?
 

jarv

macrumors newbie
Original poster
Jan 17, 2011
12
0
Thanks!

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?
 

t9b

macrumors newbie
Jan 20, 2011
1
0
Dashcode PHP and MySQL

Hi

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.
 
Last edited:

carlosbutler

macrumors 6502a
Feb 24, 2008
691
2
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: http://foundationphp.com/tutorials/php_leopard.php
 

jarv

macrumors newbie
Original poster
Jan 17, 2011
12
0
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?

J
 

jarv

macrumors newbie
Original poster
Jan 17, 2011
12
0
I just added a PHP page to my project with <? echo 'hello'; ?> and navigated to it, nothing happened?! hmm well, it turned out blank!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.