Saturday, October 22, 2011

Frapi (PHP web service API system)

I read about Frapi in PHP Architect (May 2011), and spent a couple of hours trying it out. It is quite interesting, but I don't think I will be using it. It is a full web-interface for making the API. This is what makes it cool, but also its biggest disadvantage. There is a lot of code involved, meaning there is a lot to learn if you need to change it and lots of places for bugs and security exploits to crop up.

It comes with a documentation generator, which could be really useful. This feature is still incomplete (for instance there are no links to it yet, see here, PDF generation didn't work properly), but it looks okay.

There is one specific limitation: I could not create an action with an optional parameter, at least not using the router.  E.g. if my action is called "ddd", then I can call /ddd (no parameter). But I cannot call "/ddd/77". (I can give an optional parameter with /ddd?id=77). Or I can define a router as "/ddd/:id" so that I can call "/ddd/77". But in that case id is now required and I cannot use "/ddd".

Another disadvantage is no built-in support for oAuth. (I did find an oauth extension for Frapi but did not try it as the integration seems quite rough still.)

Incidentally if you were looking for a full application built on Zend Framework this may make the perfect study case. Apparently only the admin interface uses ZF, and the actual web services do not; but as far as I can tell they are closely tied and you need to keep both together even on your production servers.

Overall, because making a web service in PHP is not that hard, the advantages are slight and not enough to outweigh the disadvantages (large codebase, inflexible structure, etc.).


Arul said...

Another alternative that you may want to try is Luracast Restler it converts any PHP Method into RESTful API and does two way conversion of various formats including JSON, XML, YAML, AMF, Binary and XML PLIST.

Start with the Live Examples

Unknown said...

By the way, I did take a look at Luracast Restler, and liked the design. But I didn't give it a proper evaluation as by that point I'd already half-written my own web service framework. (Like I said it is not that difficult; in fact I spent more time on getting the test client working!)

YaBa said...

I've also tried it and hated.
- Documentation sucks and lacks details
- No examples given (except by the community.
- Sucks real time to have 2 hosts for it.
Anyway... still better than Recess! because it can support some kind of auth :|
Argh... I just can't find a good web based framework for my needs.