Knowpapa.com - a developer's blog

PHP & MySQL Scaffolding Made easy for Non-MVC Environments

Scaffolding enables easy creation of codes to handle the “create, read, update and delete” (CRUD) activities on database entries.

While Python (read as:Django) or Ruby on Rails offers simple ways for scaffolding, I did not find any equivalent for PHP.

All this while I used PHPmyAdmin to populate and play with my database structure, but there are better ways to do it.

Scaffolding in MVC Environment for PHP

If you are using a MVC frameworks like codeigniter, Yii or CakePHP for PHP development, all you need is to add a class variable $scaffold and set it to point to the name of the model you want to scaffold.

For codeigniter, all you need to do is to load the scaffolding feature, within the constructor.

this->load->scaffolding ('name_of_the_database_table_you_want_scaffolded');
//you also need to activate the scaffolding feature within config >> router to
specify the trigger word which will open the scaffolding window.
}

Scaffolding in Non-MVC frameworks for PHP

For those of you not using the MVC framework, there is an excellent site called phpscaffold.com that lets you quickly generate your CRUD scaffold pages for PHP and MySQL by pasting your phpMyAdmin export SQL queries for the table for which you want to generate list, edit, new, and delete pages.

Once you download the generated pages, all you need is to add them to your development server, make changes to connect to database and you are done.