Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8565747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:29:56+00:00 2026-06-11T17:29:56+00:00

I was wondering if controllers at CakePHP should not contain any private function which

  • 0

I was wondering if controllers at CakePHP should not contain any private function which is not accessible by URL.

Sometimes some functions such as add or delete can be so large that I prefer to divide them.
Should I put that functions inside the model instead of making then private on the Controller?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T17:29:57+00:00Added an answer on June 11, 2026 at 5:29 pm

    Yeah it’s probably for the best if you keep your methods in the Model. Like you yourself have mentioned in the comment, “keep models fat and controllers thin”. The controller is just a medium which is supposed to interact between model and view.

    The problem comes when you have to deal with changes in datasources, tables. If your controllers are fat, you would have used the fields everywhere, and now you will be left with cleaning the whole setup in places where it wasn’t supposed to be.

    The added benefit of methods in models is that you can call it from other models and reuse the code. For example:

    class User extends AppModel {
    
         public function getAllActiveUsers() {
             // return active users
         }
    
    } 
    

    The above method can be accessed by every other methods in both model and controller, which is related to the User.

    If you need such functions elsewhere and if you don’t have them defined in the User model, you will either end up redirecting it to the controller or writing the whole logic all over again.

    The redirecting thing isn’t that bad but consider what happens if you have rewritten the logic elsewhere, and then your implementation of ActiveUsers changes. You will end up having to correct things everywhere.

    However, there are a few things that have to be done in controller. For example, if I have to calculate the distance between the user’s geolocation and all the matching restaurants for a nearby distance, I should do this in the controller. But it is in the best interest that the controller is left thin, and components exist for this purpose. You can create your custom components for complex and lengthy logic.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using CakePHP 1.2 and I'm just wondering if there is any side affect
I'm wondering if it's possible to rewrite URL for all controllers in a particular
I am wondering if anyone is familiar with any STM32f10x micro-controllers? If so, I
I was wondering how I go about adding a # to a cakephp url
I'm wondering which option is better; create a normal folder under controllers folder or
I was wondering how you find it most easy to setup your controllers. Do
I was wondering if there was a standard way for backbone models/controllers to handle
I have an User(plural) and a Subscription(singular) controllers. I am wondering if I can
I am wondering if there is any other configuration options for a default controller.
Wondering if any of you can help me: I've made a signup modal that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.