Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CodeIgniter CRUD structure

I'm using Codeigniter to flesh out a pretty large project (especially for a n00b). One issue I'm having is how to organise my files and methods. I've broken my project down into features - the app is a task management software so already we have basic features such as "Task", "Project", "User" etc.

The way I intend to do this is by creating controllers for each and then following CRUD methodology in each. So for example in Task we would have the following methods:

create()
read()
update()
delete()

This makes sense in my head. Now in terms of Views, should I have multiple views, or should I combine create and update into the same form? Also, where does non-View functionality go, such as setting cookies etc?

This is quite a specific question but if anybody has any more holistic guides on general structure convention for CodeIgniter projects I'd be very grateful.

like image 465
Matt Saunders Avatar asked Aug 25 '26 02:08

Matt Saunders


1 Answers

I'd say you got it right. This is what I do.

I tend to use the same view for create and update, keep it DRY (don't repeat yourself) if you can.

Non-view related stuff that does not handle anything business-related goes in what I call helper-classes. If it's business related, I put all the logic into services, so I can unit-test them without being dependant of any framework (not sure how new you are at this, but oh well :) ).

like image 192
Jeff Avatar answered Aug 27 '26 17:08

Jeff