Crud PHP, a 1 minute demo

I was able to generate a very basic PHP crud demo in about a minute….
And here it is.

http://www.crudphp.com/demo/list_person.php

With a very small amount of work this could be massaged into a data entry screen for your application - and with CrudPHP it took a tiny amount of time to generate!

Technorati Tags: , , , , , , , , ,

Getting started with CrudPHP

  • Create a table in mySQL (with an auto number int primary key) 
  • Unzip your release of CrudPHP into a directory on your web server. 
  • Generate the crud by running generator.php (which will be in the CrudPHP directory). You will need to enter the name of the table you want to generate crud for, the name of the database you are creating it against, the username and password for the database, and the host server for the database. After you have entered those details hit submit. 

  • Your crud will then be deposited into the generated directory. Time to check it out… Go to the generated directory and run the program named tablename_list.php

Click around and check out the show, update and delete functions.

 

 

  • Now that you are done playing, copy all of the components out of the generated directory into your application development directory wherever that might be. It should all run fine. You can now customise the generated code to do whatever you want… hopefully it has saved you some time.
  • A final word of advice, when editing the generated code, make sure you are using a unix CR compatible text editor.

Enjoy,

Chris.

Technorati Tags: , , , , ,

CrudPHP 1.7 released Sat 9th September

Hi Developers,

thanks for using crudphp by Christopher Low (christophermichaellow@crudphp.com) - if you like it then drop me a line. If you hate it, drop me a line.
If you have any ideas as to how I can improve it… Drop me a line.

What is it?

CrudPHP is a CRUD code generator for PHP and MySQL.

Crud code comprises all code who’s function is to perform the basic database operations of creating, reading updating and deleting database records.
CrudPHP massively reduces the amount of effort required in writing CRUD code by generating a working skelliton / prototype of the code you need to work with a particular table within your MySQL database, leaving you to tackle the more intricate (and enjoyable) aspects of web application development like design and coding complex business logic.

Why was CrudPHP written?
 
I really like the idea of rapid application development, and turning an idea into something concrete as fast as possible. Because of this, I spent some time investigating rails, particularly for it’s scaffolding. After thinking “yeah, this is nice”, I decided to make a trip to the local bookshop to try and find some good reference materials on Ruby and Rails and was unable to find anything more than a book ”Rails for Dummies” which wasn’t comprehensive enough for my tastes. This led me onto a tangent, which was to investigate other web languages which brought me to PHP. After playing with PHP for a while, and enjoying it’s simplicity I decided that it would be a good idea to find some sort of CRUD generator to use - which I could not find any that did exactly what I wanted. Most seemed to push OO architecture - of which I am usually a proponent, but not in this case.  Why would we want to read records into a collection of objects? - Not really practical when we are dealing with thousands and thousands of records.
When I finally settled onto the idea of writing CrudPHP, a code generator that would product procedural style PHP code, I was searching away on the web and I found an article written by Bastien Koert www.bastienkoert.net, in which he presented some code which traversed the meta schema of a MySQL table and produced SQL queries for inserting and updating records in those tables. I have leveraged his code sample in order to produce a fully fledged code generator.

How to use
Firstly, make sure the first field in your tables (the primary key field) is an auto numbered integer. If you have a name field in your tables, make that the second field.

  1. Edit create_tables.php in the lib directory to create your initial schema.
  2. Run create_tables.php - and it will load your schema.
  3. Generate the crud by running generator.php (which will be in the CrudPHP directory). Your crud will then be deposited into the generated directory.
  4. Copy all of the components out of the generated directory into your application development directory wherever that might be.
  5. Run one of the list programs (that will be named tablename_list.php) to check that your newly created crud is working properly. 

Extraneous Notes
If in the future your database parameters change i.e. host, username, password you can edit config.php which sits in your application directory (and was originally generated in the generated directory).

Make sure you are developing your PHP code in something that understand carriage returns i.e. JEDIT, otherwise the code created by CrudPHP will be all clumped together.

Future Development

If there are any keen developers out there that might want to add features to CrudPHP  to make it a better piece of software, feel free to make those changes and then e-mail them back to me and I will include them in the next release (and obviously give you props for your work).

To obtain the latest version of crudphp, please visit http://www.crudphp.com

Technorati Tags: , , ,