Welcome Guest, Not a member yet? Register   Sign In
My PHP CodeIgniter controllers are getting huge. Seem like God Objects. Is there a better way?
#1

Seems pretty large. There's no reason you can't do one method per controller if you want to. My guideline is to create a single controller for each domain (user management, role management, etc), and then break those into further controllers if they start feeling too large.

You can create other controllers to extend your controllers from if you need common things handled, like Auth, etc. You can also put controllers in folders if you need to organize them or the URI more.
Reply
#2

(This post was last modified: 04-01-2020, 07:56 PM by TheAdmiral.)

Hey @kilishan,

Thanks for taking the time to reply to this. Whoever this guy Raymond is, he stole my question from Reddit word for word in his post above. He is either a bot or a plagiarist. Definitely keep an eye on his account in case he is a bot.

https://www.reddit.com/r/CodingHelp/comm...ting_huge/

Thanks for suggesting one controller per page. That is a good idea and nobody else has suggested that yet. I will look into it.

This is my first visit to the forums. I read about CI4 (I am currently on CI3) and I am excited and gathering more info. If it's an easy upgrade, I will upgrade the website mentioned above to it. Thanks for all your time invested in this project -- CI is a great framework.

edit: Ah, I see what Raymond is doing. He put links to 3 websites in his signature. He is trying to advertise for his websites, using MY reddit content. Bad Raymond.
Reply
#3

Hi, This is now one odd looking thread. As I can't re-arrange the thread. But I have now removed the first one (and the account).

PS. Moved it into Best Practices instead.
Reply
#4

Thanks for the coding help and the quick action against Raymond.

Is upgrading from CI3 to CI4 difficult, or are most of the framework method names the same?
Reply
#5

It's a complete rewrite of the framework, please see this part of the manual
https://codeigniter.com/user_guide/insta...e_4xx.html
Reply




Theme © iAndrew 2016 - Forum software by © MyBB