I always sayd that one of my aims was to develop an “important” framework to make PHP work like Ruby On Rails. The first alpha/unstable/use-at-your-own-risk version will be probably released in the first months of 2010. You know…I have to work, so my experiments are done during my freetime (especially at night…). So if you appreciate my “second” job as a web development researcher you can contact me for a donation via PayPal. But now let’s talk about PhpOnTheRoad, my new PHP framework!

Basically PhpOnTheRoad (POTR) let’s you easily develop your web-app writing less code as possibile, being inspired from RubyOnRails. IMHO web sites always do the same things.
Generally in a web site you can find:
- some products or a catalog of products, divided into categories and sub-categories, with images, attachments and so on…
- users: almost the 95% percent, I think, of the websites on the internet have some “register” button which allow the user to receive newsletters and/or to access some contents unavailable to not registered users.
- some generic contents, which can be pages, files, links to other resources and so on
- e-commerce: many web sites allow registered users to buy something, paying using credit card and receive what they bought at home

The aim of my PhpOnTheRoad framework isn’t do this things for you, but let you do them in almost half the time or less.

The basic idea of the PhpOnTheRoad framework is that you have to “describe” the contents you are going to edit. I’ll show you an example of usage, which is very clear.
Think about the classical user registration. We need something called “User” (maybe a class?) to handle users’ registrations on our web site and store users’ data in a DBMS.
There are always the same field, like username, email, password, etc.
In POTR you can create a class User which extends the framework provided class ActiveArray:

class User extends ActiveArray {
  public function __construct(){
    parent::__construct("users");
    $this->addField("id",AA_INTEGER_PRIMARY_KEY);
    $this->addField("first_name",AA_STRING);
    $this->addField("last_name", AA_STRING);
    $this->addField("address", AA_STRING);
    $this->addField("city",AA_STRING);
    $this->addField("avatar", AA_IMAGE_WITH_THUMB);
    $this->addField("email", AA_STRING);
    $this->addField("password", AA_STRING);
    $this->addAccessor("password_confirmation", AA_STRING);
  }
}

This is what is called model. It takes some inspiration from RoR’s models, but I think I have done something better. This extends the ActiveArray class, whose functionality is similar to RoR’s ActiveRecord, but it creates an object that gives you back an array, using them find($id_to_find) method. I choose this way, because I think php developers are more used to work with arrays and hashes than objects.
Functions and methods like mysql_fetch_array() or MDB2::queryRow() (from PEAR) give you back arrays as default.

So we described how the entity “User” is composed. In your POTR Controller you just have to write something like:

class UsersController extends ApplicationController {
        public function docreate(){
		$user = new User();
		$user->create($_REQUEST['user'],$_FILES['user']);
		$this->V['data'] = $user->getData();
       }
}

The POTR framework will do all the dirty work for inserting images and handling password. This example is very minimalist, there is no check on the inserted data and there are no validations: e.g an image should be an image and password should match its confirmation. They haven’t been implemented yet (maybe this is one of the reasons it’s still unstable and unreleased???) but they will be soon included, letting you also define your custom validations, which will be run before the insertion of the record into the database. But it will create the record, upload images and creating thumbs for them!!! No extra programming required!

What about HTML? We need only few lines to get this thing work…oops only one. You should create a view and name it as the controller function (in our example docreate.php) and put it in the right directory.
Just add this line to the docreate.php file:

<?=auto_form_for($this->V['user'],"/users/docreate")?>

And your almost done. A new shining form is on your browser! What do you think about PHP On The Road? Isn’t it a lovely framework (or almost it will be)? I think my new framework will be second only to few other web development frameworks. My aims include to integrate ajax and some nice stuff like mootools and ReMooz. Any advice, suggestion, thought or else is well accepted. Please let me know!

Obviously all these contents can change before the first release, but these are the main ideas I want to put in Php On The Road.
Thanks for reading!