How is MVC supposed to work in CodeIgniter

前端 未结 3 737
春和景丽
春和景丽 2020-12-04 22:52

As a mostly self-taught programmer I\'m late to the game when it comes to design patterns and such. I\'m writing a labor management webapp using CodeIgniter.

I did a

3条回答
  •  旧时难觅i
    2020-12-04 23:47

    CodeIgniter is very flexible when it comes to following the MVC pattern and it's really up to you how much you want to enforce it. Most of the CodeIgniter code you will find online is exactly like you describe, the Models are just a collection of methods really, and don't strive to strictly represent an object.

    You can, however, code that way too if you so like within CI (and this is something I often do). It makes the code much more maintainable and readable, and just seems better all around.

    PS - If you're just getting into MVC in PHP, you might want to look around a little. Frameworks like CodeIgniter and CakePHP are (somewhat) of a previous generation. CI was initially written for PHP4 where OOP support was kinda spotty in PHP. A fork of CI, called Fuel, was specifically created to address this issue (though I believe at some point, they just decided they would be better served by rewriting it from scratch). CI does have the advantage of having a lot of documentation and help online since it is more widely used than Fuel.

提交回复
热议问题