Re: PHP Framework w/ mysql support
- From: Henk Verhoeven <news1@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 06 Apr 2005 22:18:06 +0200
Hi Angelo,
It sounds like you do not need much from a framework. If i where you i would not bother about downloading and selecting a framework for something as simple as what you want.
Writing your own framework is simple enough in this case. Just write the code you need for one table and page, but don't put any code in the basic script. Put everyting in functions, of if you are used to OOP, in classes with functions. Try to avoid function to become longer then 10 lines. Put the design of the page into an include file and include that file from a function. Dont put any more code then a simple function call in that include file. Dynamic values will typically look like
<?php printFormField('fieldName') ?>
While you are writing the code for the first page, already look for existing code that did the same or a similar thing as you are currently writing. Never write similar code as you wrote before. Instead call existing functions. Eventually put the code that you need to reuse into a separate function, maybe with some parameter to make it work for both cases. This is called refactoring. Before you start refactoring, test your code. Ater you refactored, test it again, it shoulf give the same results.
Repeat this process over and over. Go on with the second page, but now move every function that is called by both pages to a separate file and require_once that file from both pages. Also move all functions that are called by those function to that file, recursively. For the rest just repeat the process of writing functions, calling functions and refactoring. Allways take into account all the code you wrote before. Never write code similar to code you already have. Allways refactor as soon as you find code that somehow escaped from this and at hindsight seems similar.
If i am right, when you are at the fourth page, the code of each page has becomed very small and you have a whole lot of functions that can be used for a variety of purposes. That's your framework. Writing the framework was about as much work as writing the code for three or maybe four pages. It only required that you did refactoring instead of repeating yourself.
Greetings,
Henk Verhoeven, www.phpPeanuts.org.
(BTW, given your description the phpPeanuts framework will be overkill for your purpose. PhpPeanuts uses object orientation with a layered architecture and persistent objects and produces a variety of pages composed from standard parts. You just seem to want a simple two tier aproach with very few page types. So i suggest you avoid phpPeanuts ;-) )
Angelo Amoruso wrote:
Hi All,
I'm looking for a free/GPL PHP framework able to generate at runtime HTML
forms and handle the retrieve/update/insert data inside MYSQL tables.
It would be cute if such framework can handle data validation via Javascript too, but it would suffice also done at POST time.
I've searched on Freshmeat (http://freshmeat.net) but there are too many to
start to tryout each one.
Some time ago I tried BlueShoes but I found it too difficult. My needs are just:
- pickup a record from a table (choosing which fields to edit and which one
only show or hide)
- allow user to change the values - put back the updated info on the table.
Since I need to handle more than a couple of tables, I'd like to avoid spending too much time writing (and mantaining) form handling code, instead of "real business" code. ;-)
Can you suggest any PHP framework you're using, or otherwise suggest which ones to avoid :-)
Regards,
Angelo
.
- References:
- PHP Framework w/ mysql support
- From: Angelo Amoruso
- PHP Framework w/ mysql support
- Prev by Date: updating cookies
- Next by Date: link to include
- Previous by thread: PHP Framework w/ mysql support
- Next by thread: updating cookies
- Index(es):
Relevant Pages
|