Ian Bicking: the old part of his blog

Why web programming matters most comment 000

Sick as it may seem, I'd recommend exploring Python as an active generator for PHP

Yes Harry, that does seem sick. Sick! Horrible! The debugging horror! The deployment nightmare! That is the framework I really, really don't want to see... maybe if you keep it in the basement and never tell the neighbors it was ever born it would be okay. But do not reveal such a thing to the light of day, please!

Comment on Re: Why Web Programming Matters Most
by Ian Bicking

Comments:

Oh well, guess you don't want to see this http://eric_rollins.home.mindspring.com/pgen/ - Ruby again ;)
# Harry Fuecks

Apologies - got rant some more;

"Sick! Horrible! The debugging horror! The deployment nightmare! That is the framework I really, really don't want to see..."

Perhaps as a general framework, yes but for more specific application, where the design stage involves a narrower range of choices, it can work well.

There's a perfect example I forgot - Worksheet Server: http://www.jedox.com/. Design / development is done with Excel and the generated PHP code is not meant to be touched directly - it behaves something like a "component" on the web server. Further changes are made in Excel, overwriting the previous set of generated PHP code. So PHP acts as something like the "byte code" of a Worksheet Server "runtime". Did a review of it a while back http://www.sitepoint.com/article/php-apps-excel-worksheet-server.

And a potential candidate would be tools like JAlbum (http://jalbum.net/) which normally spit out HTML. Could easily be used to spit out PHP and add all those features some people seem to appreciate on their galleries, such as hit counts and comments.

Otherwise the devil is in the details - I don't see debugging horrors and deployment nightmares as givens - depends what you're doing and how you do it. Sure anything that involves generating code will itself require significant development overhead but

As one simple example of Python aiding PHP development, using Ned Bachelors COG, you might have something like:

<?php
/*
[[[
import cog
from myapputils import getdsn

dsn = getdsn()
cog.outl("$db = DB::connect(%s);" %dsn)
]]]
*/

# While developing use this (will be replaced by COG)
$db = DB::connect("pgsql://devuser:password@localhost/myapp");

//[[[end]]]

# Continue with PHP script...
?>

The PHP script is still executable while hacking / debugging is in progress. Deployment could be a Python script that runs COG over the source then copies it to the producive environment, replacing previous versions.

Anyway...

# Harry Fuecks

I think it's reasonable when using static publishing to produce PHP. I'm not against all PHP generation. But I think it's important to keep the generation dumb; set some variables, include some other PHP files (which are custom written), and that's about it. It's the modeling in Python and generating PHP that would scare me.
# Ian Bicking