You can follow the official install page to install Google App Engine for PHP, or follow my steps here. I am using osx 10.8.3 and I use brew instead of macport.
First you will need to get php 5.4. What you have is probably 5.3. You can verify by php -v, and something like this comes out.
PHP 5.3.15 with Suhosin-Patch (cli) (built: Aug 24 2012 17:45:44)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
That’s the default/latest php version for osx 10.8.3. To install php 5.4 using brew, according to https://github.com/josegonzalez/homebrew-php, do the following.
brew tap homebrew/dupes
brew tap josegonzalez/homebrew-php
brew install php54
You may run into permission issues when running brew install php54. You will need to use chown and chgrp to give brew access to some of those directories under /usr/local/.
After installing php54, double check by issuing ls /usr/local/bin/php*. You should see php and php-cgi there. Run /usr/local/bin/php-cgi -v and you should see something like the following.
PHP 5.4.15 (cgi-fcgi) (built: May 15 2013 18:27:50)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
Confirming it’s 5.4. Then move on.
Download and unzip the SDK in your home directory. (or you can pick any other directory, doesn’t matter).
curl -O http://commondatastorage.googleapis.com/appengine-php/appengine-php-sdk-1.8.0.zip
You will then have the google_appengine folder. Here, to avoid confusion in the future, I prefer to rename this folder in case you may do app engine programming in other languages.
mv google_appengine google_appengine_php
Now we can write and test the hello world program. Create a directory for your app.
Then create the app.yaml file. This is standard for any app engine projects. For yaml reference look here.
- url: /.*
Then create your helloworld.php file.
echo 'Hello, World!';
Yea, it’s without the closing ?>. I am not sure why either. But if you add the closing tag back in it will work as well.
Now, issue the following command to start your web server.
~/google_appengine_php/dev_appserver.py --php_executable_path=/usr/local/bin/php-cgi ~/helloworld/
If everything goes well, you should see your hello world text at http://localhost:8080/.
If you are thinking about deploying your app, make sure you create your app at https://appengine.google.com/ and go to https://gaeforphp.appspot.com/ to register first. The waitlist is building up. I see 73 applications on the list as of now May 15th, 2013 at around 7:30pm. This registration process hopefully will go away soon.
One more thing, there are more php54 libraries. See the list by brew search php54. They may be useful/crucial for your new app!
Happy app engining!