I previously blogged about my theories on separation of functionality and how I wanted to setup a RESTful app API methodology in the nexista PHP / XSL / XML framework .
Its now in motion and its working well. Here's some quick updates on the matter:
- The requester is a nexista action called curl.action.php and appropriately uses the libcurl client functions to make the request and handle the response.
- It uses the same session as the current accessing browser.
- It takes the following parameters:
- params (most likely an xpath reference)
- target flow node to store the results
- The rawxml.action.php is also used to parse he result into flow as a set of nodes rather than a string. This might be possible within curl.action.php.
- I modified flow.php to add a parameter for requesting an associative array.
- Should only unique parameters be passed? i.e. - should a request contain a duplicate value for the same parameter name: userid=100 and userid=100? I don't think so and I setup curl.action.php to filter dups out.
- Is there a common REST response format? I've seen resource tags used, as well as XLINK attributes, though the wikipedia article on Representational State Transfer I read was vague on the difference between REST responses and Plain old XML (POX) responses.
In other Nexista news, I hacked my way through adding configurable support for data access entities, aka custom table names and table name prefixes. It still needs some work, but the idea was inspired by the table prefix method used by Wordpress and many other great apps. With Wordpress on debian specifically, I really like how easy it is to create new database table prefixes based upon server name. Here's what I use:
$specific_site = str_replace('.','',$_SERVER['SERVER_NAME']);
$table_prefix = $specific_site.'_';
$server = DB_HOST;
$loginsql = DB_USER;
$passsql = DB_PASSWORD;
$base = DB_NAME;
I'm starting to feel that Nexista is more of a web application framework than a php application framework.