Web.php

Web.py is a really nice lightweight web framework written in Python. It’s not trying to be Rails or Django, it’s trying to be as simple as possible. Web.php is my homage to Web.py. I’ve unashamedly copied the ideas and build a very simple web framework in PHP. It’s not a complete port, nor does it do everything in the same way.

The code example from the project home page was what originally piqued my interest:

import web
urls = (
   '/(.*)', 'hello'
)
class hello:        
   def GET(self, name):
       i = web.input(times=1)
       if not name: name = 'world'
       for c in xrange(int(i.times)): print 'Hello,', name+'!'
if __name__ == "__main__": web.run(urls, globals())

My PHP versions goes something like this, I’m sure you can see the similarities:

<?php
require('webphp/web.php');
$urls = array(
   '/' => 'hello',
);
class hello {
   function GET($path) {
      echo 'hello world';
   }
}
web::run($urls);
?>

I’ve used it so far on a couple of projects, but it’s never been properly tested as such nor do I have lots of time to develop it. It’s purposely feature and code light (the core file is only 80 odd lines of code, includig comments).

Download Zip

Comments

  1. I would really like to continue on web.php
    Is the code gpl? I’m probably going to open a group on google code for it
    Let me know,
    Thanks.

    Luca - 6th August 2007

  2. [...] day job didn’t need me to and also because I like playing with new toys. I even tinkered with my own homage to Web.py in PHP which a few people have picked and are running [...]

    Morethanseven > Getting going with Symfony - 16th September 2007

  3. I actually created my own port and have gotten pretty far with it. I just saw yours now and downloaded your example, everything is pretty good except for where you use eval to run the method and how parse and match the request_uri, but otherwise we are going in a similar direction. You can check out my version if you want at: code.google.com/p/webpy-php-port/

    kenrick - 14th May 2008

Comments are now closed.