How to get started with MVC? S

Discussion in 'PHP' started by nile1483, Sep 5, 2011.

  1. #1
    Dear friends,

    I dont know is it called MVC or not, I want to develop Custom CMS , I dont want to write too much php code in template file like wordpress.

    e.g. if i want to add menu in template file i will call it by <php get_menu("menuid1"); ?>, similarly for page title <php get_page_title(); ?>

    I know how to write function and call them but my question is i dont want to linkup any php file with template file e.g. i dont want to such code in template file <?php include(function.php) ?> etc.
     
    nile1483, Sep 5, 2011 IP
  2. ssmm987

    ssmm987 Member

    Messages:
    180
    Likes Received:
    4
    Best Answers:
    3
    Trophy Points:
    43
    #2
    Use a bootstrap file (controller), witch includes handler (model) files and the template (view) according to the user input.

    You can include a file with all the functions you frequently use throughout the websites (The get menu, en get page title functions for example) which you include on every page in the bootstrap file, and you can include another file which holds the function used on that page only.

    That's how i've always done it.
     
    ssmm987, Sep 5, 2011 IP
  3. MayurGondaliya

    MayurGondaliya Well-Known Member

    Messages:
    1,233
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    170
    #3
    I would suggest you to use codeigniter or cakephp which have in-built MVC and helper classes.
     
    MayurGondaliya, Sep 5, 2011 IP
  4. sarahk

    sarahk iTamer Staff

    Messages:
    28,899
    Likes Received:
    4,555
    Best Answers:
    123
    Trophy Points:
    665
    #4
    Why do you want to recreate the wheel?

    All MVC means is that you have different files doing different jobs - specialists!

    The benefit of leveraging off WordPress, Joomla, cakePHP is that you benefit from the combined efforts of a group of people who have worked out a solution to the most common problems. WordPress and Joomla are already a CMS. I've written a CMS in cakePHP (which is a framework) and while it does the job it is no where near as fully featured as the other two (and not available to anyone but the client using it) but I have cake doing things the other two would be awful at so its a successful compromise.

    If you have someone paying for this project (given that you are a designer, you must have clients) I would query the monetary value they would get from you creating a custom CMS. Far better that they pay less for the wheel and more for the time you spend on design and customisation to fit their business requirements.

    Security issues alone would prevent me from ever starting from scratch.
     
    sarahk, Sep 5, 2011 IP
  5. insert

    insert Peon

    Messages:
    148
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Try using nette framework. It has a lot of MVC features implemented, and it has other great features - the complete list is here.
     
    insert, Sep 6, 2011 IP
  6. insert

    insert Peon

    Messages:
    148
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    insert, Sep 6, 2011 IP
  7. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #7
    If people didn't try to create better wheels, we still would drive on wooden wheels!!! that's why!

    That's sad.. cos then you don't learn from your mistakes! Every programmer makes mistakes, even those that make wordpress and others... but the community will help finding/fixing them! If that is your point of view, why even develop websites? coz everything is already build... My point of view is that i can (do/try) to make it better then a exisiting one!
     
    EricBruggema, Sep 6, 2011 IP
  8. sarahk

    sarahk iTamer Staff

    Messages:
    28,899
    Likes Received:
    4,555
    Best Answers:
    123
    Trophy Points:
    665
    #8
    Eric - you have valid points so long as a client isn't paying for the R&D.

    Any user who says
    isn't going to be at the forefront of MVC architectural progress

    As for the security comment - try telling clients when their online credibility is in tatters that its OK that the system you built was full of holes because everyone makes mistakes and you've learnt lots from it.

    I build websites to give value to my customers - not every site has to be a learning experience. Its about presenting the customer to online world in the most appropriate way. Then you get challenges like writing plugins to present data in a way that hasn't been done yet and releasing the plugin so others can benefit too (if thats ok with the client). Or writing something that handles unique data - not just articles.

    Oh, and don't be fooled into thinking everything has already been built. We didn't know we were missing facebook and twitter until someone built them. And there are sites to do USEFUL things that are yet to be built.

    We have news stories here about how dairy farmers can control farm gates using private websites so that they can call the cows in (they come quite willingly) while they're in town and by the time they get back the cows are outside the shed ready to come in. Saves the farmer a couple of hours every day. Now, if I was going to be doing R&D I'd love to be involved in something that drives productivity or increases safety. But everyone has their own "thing" that interests them. I'm just not sure the OP has the interest or skills to recreate an MVC
     
    sarahk, Sep 6, 2011 IP
  9. freelanceinphp

    freelanceinphp Member

    Messages:
    134
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    48
    #9
    I think, Start with Cake php, very easy to understand with image
    [​IMG]
     
    freelanceinphp, Sep 7, 2011 IP
  10. nile1483

    nile1483 Active Member

    Messages:
    345
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    60
    #10
    nile1483, Sep 7, 2011 IP