[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cgiapp] PHP Port of CGI::Application


I recently ported CGI::Application to PHP so that I could continue using
CGI::Application where I work, which is a PHP shop. The results are on
my own website at:

    http://weierophinney.net/matthew/content/downloads.html

as Cgiapp.class.tgz, which contains the PHP class Cgiapp in the file
Cgiapp.class.php. Documentation is included in the archive, and is also
in the class itself as POD (some habits die hard, and I find documenting
using POD in multiline comments easier than any of the alternatives I've
yet explored in PHP).

It's a straight port, though I needed to add a few static methods to do
things in PHP that I naturally do in perl (carp() and croak() are two of
these, as are array_to_hash() and is_assoc_array()); I also added a few
new methods for handling session parameters (as session handling is
native in PHP - these are s_param() and s_delete()); and some methods
were removed as unnecessary (cgiapp_get_query() and query() are
unnecessary in a PHP environment).

For default templating engine, I chose Smarty as (a) it's what we've
standardized on at work, and (b) it's a standard, well-supported choice
in PHP development. As such, the templating operations work backwards
from CGI::Application + HTML::Template: tmpl_path() creates the template
object (which I store in the _TEMPLATE parameter), and load_tmpl()
returns the contents of a template. I also added a new method,
tmpl_assign(), for assigning data to the template. In CGI::Application
style, these methods can be easily overridden when subclassed so as to
allow usage of alternate templating engines.

I ported it as I have been having trouble handling and maintaining
procedural code, especially when it needs to be reusable, and as
our code base has grown and the applications we've been porting (from
Tango, no less) grown more complex, the need for a standard, secure
methodology has increased. I've often wished for CGI::Application in our
environment, and it suddenly dawned on me that it wouldn't be too
difficult to port. I couldn't be happier with the results.

The code has been fairly rigorously tested as we use it in a number of
our private content management systems, and I've started using it in
some of our public applications as well. I certainly feel it is
production ready.

Jesse Erlbaum was kind enough to take a look at it, and told me to go
ahead and release it. I thought I'd give the perl community first whacks
at it -- as without the perl community, I wouldn't have had the codebase
to steal from (or the documentation!). 

Comments and critiques are welcome!

Enjoy!

-- 
Matthew Weier O'Phinney
http://weierophinney.net/matthew/

---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.