Re: PHP Framework w/ mysql support



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


.



Relevant Pages

  • Re: OODesign - OPF, design pattern
    ... What constantly kept getting in my way was the fact, that UI controls ... is exactly what it takes - writing wrappers and reinventing. ... The truth is, that once you have written an adapter framework for your favourite widget set, you have written it once and for all; it gets used over and over again. ... OPFs are but a small part of OO design. ...
    (borland.public.delphi.non-technical)
  • Re: Frameworks
    ... if you are writing an administrative web application and you ... As well as having all the above features it has a custom built Data ... to start with nothing more than a database schema which you then import into ... the Zend Framework, so I'd like to look into what it's all about. ...
    (php.general)
  • Re: [PHP] Frameworks
    ... I admit that I don't use all the OOP of PHP 5, but really I don't let myself be forced to use deprecated software if it is my income. ... you'll entertain yourself with our discussions for months. ... Is IQ really relevant to being capable of writing your own framework? ...
    (php.general)
  • Re: Ruby-VPI 0.5
    ... Jeremy Ralph wrote: ... their experiences? ... I don't know of any big-name users yet, but I'm writing this ... framework to make it easier to think about, verify, and implement ...
    (comp.lang.verilog)
  • Re: Seeking OO Framework Training
    ... Now our customer would like us to work on making a flexible framework ... I've found some good books that offer guidance, ... can anyone recommend training that would be ... > You may also want to study up on patterns and refactoring since both ...
    (comp.object)