Menu

File structure

Developers
cla
2005-12-14
2013-03-08
  • cla

    cla - 2005-12-14

    Perhaps it's time we revisit the structure of the generated code. Currently, ClassyPHP generates the following:

    table_name.inc  (the class)
    table_name.html (the form)
    table_name.php  (form submission script)

    I suggest for the class in table_name.inc to be divided into a pure class file and a general include file, containing the "EXTERNAL FUNCTIONS" section.

    These could then be arranged into the following structure:

    root/
      |-form1.html
      |-form2.html
      |-form1.php
      |-form2.php
      |-includes/
      |      |-external_functions.inc
      |      |-table_name_1.inc
      |      |-table_name_2.inc

    Regarding form1.php and form2.php, these files are unusable in an actual project (as they merely contain code for inserting POST data into the database using the class). This code should thus be moved to whatever file the HTML form submits to, which could be quite arbitrary.

    Ultimately (if we ever want to go there), a ClassyPHP user could create a project, model the entire project and define a chart of pages and arrows, deciding what pages submit where. In this case, we know exaclty where to put the submission handling code.

    But for now...?

     
    • Gram3000

      Gram3000 - 2005-12-16

      I like this structure. Ive begun creating a page to connect to a mysql database. It tests the connection and also outputs the code it used to try to connect. I have a folder called includes and a file in there called external_functions.php. I gave it a php extension becasue some one could open the .inc file and see the code, or is that the point?

       

Log in to post a comment.

MongoDB Logo MongoDB