3

Hey everyone! Wanna hear some advice from other PHP Developer. Is it necessary to learn MVC in PHP? And what are the benefits of it? A course link could be helpful :)

Comments
  • 1
    @Artemix Thanks!
  • 3
    I have yet to hear a satisfying definition for MVC anyways. And even within MVC, people start arguing over fat or slim models and where the business logic goes.

    MVC has become a buzzword almost void of meaning. Just like restful or responsive. It can mean everything and nothing. (There still meaning to the words, don't get me wrong. Yet in some cases it becomes vodoo.)

    I value separation of concerns more than being MVC.

    That being said, I like symfony's service-bases approach. Symfony doesn't care about being MVC. (Some people define the framework as such. I don't care.)

    A good read about that from maker of the symfony framework:

    http://fabien.potencier.org/what-is...
  • 1
    I can try explaining Model View Controller in a simple way:

    You're a client and you go to the restaurant. You make a request to the waiter (depending on the route, a certain controller will be called) that takes your request and give it to the chef to cook it. So the waiter is your CONTROLLER, that tells the chef, which is the server, what do you need from it. The chef takes your requirements and says: ok, I'll need these ingredients, so he goes to the fridge (database) and takes only what he needs. So the server (chef) is your MODEL and it communicates with the DATABASE. Than it gives to the controller what it asked for and he prepares a plate with everything the client asked for in his request. The plate is served, and that is your VIEW. :D
  • 1
    and yes, depending on you need cases, it's better to decouple your code: functionality from view. So functionality will remain in PHP files and the templating will be done in TWIG. WordPress still isn't using MVC approach by default (see Timber for that) but more complicated CMSs like Drupal changed its structure to follow this approach. It's up to you :) Hope I helped.
  • 0
    You guys helped me a lot with these explanations! Thanks all! I really appreciate it :D
  • 0
    It may not be necessary but it sure is helpful. And not just MVC but any other architecture that you can find that would let you properly understans new paradigms and concepts. I have been using MVC for a while, not because it is the best, but because it fits the needs of what I do. I will tell you this, it is one of the easiest architectures to get into which will may have the added benefit of making you a more well rounded developer.
Add Comment