Code design

Discussion in 'PHP' started by asmon, Dec 30, 2010.

  1. #1
    My projects are designed with the following way, each database table has it's class
    and then each page looks like this...
    functions related to the database are on the top and the output on the bottom
    just a simple example:

    <?php
    layout('header');
    $categories = category::find_all();
    ?>
    
    
    
    <?php foreach($categories as $category) : ?>
    <?php echo $category->id; ?>
    <img src= '<?php echo $category->pic; ?>' />
    <?php endforeach; 
    
    layout('footer');
    ?>
    PHP:
    Well, from what i've been reading, it's not too good combining design and php on the same page.
    Therefore i would like to know where can i find information about techniques of designing my projects in a better way?
    Do you have any tips or some information which can lead me the right way?

    thank you.
     
    asmon, Dec 30, 2010 IP
  2. dsdf

    dsdf Peon

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Yes, it's better if you split code and design You can search on the internet about MVC (Model - View - Controller). Code Igniter framework is the good example to start about that.
     
    dsdf, Dec 30, 2010 IP
  3. asmon

    asmon Member

    Messages:
    56
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #3
    Ok i've been reading a little and overall it's not far from what i am doing.
    My current classes are actually Modules and all i have to do is to split my view pages
    into controllers and views...

    The question is, should i stick with this and improve it overtime for my own preferences or to just jump into a framework such as CodeIgniter.
     
    asmon, Dec 30, 2010 IP
  4. Tutorial Feed

    Tutorial Feed Peon

    Messages:
    29
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    It could be worth reading up on Code Igniter if you are wanting to use an MVC framework. It is one of the better known ones and have a fair few tutorials around that you can read up on. If you are looking for an alternative, try looking at CakePHP too
     
    Tutorial Feed, Dec 30, 2010 IP