user1320990
user1320990

Reputation:

CodeIgniter - Splitting controllers

I'm developing a product review website with CodeIgniter, but I'm having some trouble splitting the controllers.

This is what I've already done:

Categories - Categories, subcategories... Main - Only the home page Products - Only the product page Users - Login, Register, Account... Reviews - Only the page to submit the review

Is this "right"?

Where should I place pages like contact, about, help...

Upvotes: 1

Views: 389

Answers (1)

Brendan
Brendan

Reputation: 4565

This is a topic that many have strong opinions on as organization is very subjective, especially in programming.

However, for me, I generally organize my controllers according to the main type of data they access or main type of role they will perform.

In respect to types of data, you might have:

  • controllers/products.php (for products, reviews, and viewing product reviews by category)
  • controllers/page.php (for page content, either a method for each page or a view method for accessing via db)

And in respect to roles performed, you might have:

  • controllers/auth.php (for login, logout, register, etc)
  • controllers/settings.php (for editing profile, etc)

Upvotes: 1

Related Questions