Help to apply onion architecture in codeIgniter |
Effectively you have to split and organise your code between controllers and models in a way that separates logic from presentation, which is easier said that done.
Here's an example in Laravel, but same principles should apply: https://medium.com/@matthew.erskine/lara...1a3d5918f2 He has first example where some of the default values are set in controller level, where it makes much more sense to individual model to handle that, so in second refactored part he's moved it to model side. Personally I don't agree where he has put his shelf validation, but I'm not familiar enough with official definition of "onion architecture" to argue if it also should or shouldn't be handled by model. Also, not sure how much framework dependency this would give you, CodeIgniter in at least in 3.x, and I imagine Laravel too, the models are pretty integral to how the core framework works, and relay heavily on framework base code to handle specific things for them. Any particular reason you are worried about framework dependency so early on? |
Welcome Guest, Not a member yet? Register Sign In |