As I mentioned in my previous post, I’m currently working on an open-source project called ZendR. ZendR is designed to help PHP/ZF2 and MySQL users perform data analysis and create awesome data visualization using the power of R.
This fills the gap between simple web development in PHP and statistical sophistication in R. Applications include:
- academic research,
- surveys creation and analysis,
- business reporting,
- machine learning on PHP-based website,
He’res the first one:
As a PHP developer, I want to import a CSV file and display descriptive statistics based on its content in simple HTML:
By simple statistics I means things like creating cross-tables(which is a pain in SQL) and computing simple descriptive stats such as mean, median, quantiles, standard deviation, etc.
I suspect that once these are implemented, calling other stat functions available in R would be trivial; that’s the aim anyway. The idea is to hooks PHP and R together in the most flexible way possible.
The first challenge is to find a way to run R scripts through PHP and to get the output in the desired format. It turns out several solutions already exist for this, and of course none of them are perfect. There’s rApache, which looks very powerful and is up to date but is tied to Apache for the server part of things(it’s actually an Apache module, not specific to PHP), which I’d rather not do given that installing an Apache module is quite involved; I’m also aware the nginx is getting more and more popular, which might make ZendR useless on many servers. There are also many blog posts that document how individuals did it with bits of code, but there are many security issues to take into account, not to mention that they are mostly out-of-date.
I finally settled on R-php, which is also quite old, but is very close to ZendR and seems to be just what I’m looking for. Of course it will need some rewriting and adapting. Studying this little beast should be fun
Leave a comment to tell us what sort of thing you’d like to do with ZendR, and fork the hell out of the project if you want to give it a go! Any feedback will be much appreciated.