PhpRiot
News Archive
PhpRiot Newsletter
Your Email Address:

More information

Want your own Cloud API?

Note: This article was originally published at Planet PHP on 10 August 2010.
Planet PHP

Ever considered developing a RESTful API? Ever wondered what is FRAPI and how it works? Well apart from reading the frameworks's website, there was no real way to assess FRAPI as a RESTful API Framework - Not until recently.

In order to ease adoption and make it more accessible for people to evaluate FRAPI, we've put an Amazon AMI together. This AMI comes pre-installed with Linux Lucid Lynx (Ubuntu 10.04 LTS), NGINX as the webserver, Memcached - (And no, port 11211 isn't opened to the public), PHP5-FPM, APC and obviously FRAPI.

If you'd like to give this public AMI a spin, just go to Amazon's instance management section, click on aoLaunch Instance, go to community AMIs, and search for : aoami-8c28c3e5a . Once you found it, click on aoSelecta (And make sure to select Port HTTP (80) when asked about which ports to open).

It's running, now what?

You can go directly to the AMI's host name in a browser and you will get FRAPI's default invalid action error, or you can follow these steps to customise it a bit more.

Now that you see your new shiny FRAPI-AMI instance running in your management console, you have a few options:

First option is: Find the aoPublic DNSa and the aoPublic IP Addressa of the instance you just launched and point your domain-name's DNS to the IP you found - Your domains could be: api.mydomain.com and admin.api.mydomain.com

Second Option is: If you do not currently hold a domain name for your API, edit your /etc/hosts file (Or the equivalent in your OS) to have an entry that points to the IP of your instance

10.0.0.1 api.mydomain.com admin.api.mydomain.com.

Once you are done with either Option 1 or Option 2, you'll need to connect to your instance over SSH (ssh ubuntu@hostname-of-the-instance -i your-amazon-cert.pem). Upon connection, you'll be greeted with a welcome screen giving you some information about FRAPI and the server's software :

Once you are connected, make sure to aosudo sua and then edit the files that are in /home/ubuntu/sites/. The only thing you have to modify in those files are the aoserver_namea details. Put either your domain name or your made up domain name that is setup in your /etc/hosts file. The end result should be an admin file with something that contains something along the lines of

and an api configuration file that contains

Don't give up, you are nearly there, now you have to run : ao/etc/init.d/nginx restart && /etc/init.d/php5-fpm restarta and you are done.

If you go to the api.mydomain.com in your browser you should now see FRAPI's default invalid action XML error. If you go to admin.api.mydomain.com you should be able to login with the username aoadmina and password aopassworda - Hint: You should go to the aoconfigurations - usersa section and modify that password.

I want to code something!

SSH into your instance, and go to /home/ubuntu/development/custom/Actions, you will see all your API Controllers there and you can follow the steps here "/

Truncated by Planet PHP, read more at the original (another 814 bytes)