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 8964181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:31:45+00:00 2026-06-15T16:31:45+00:00

I’m having a problem understanding the difference between component, utility and behavior. I read

  • 0

I’m having a problem understanding the difference between component, utility and behavior.
I read the Cookbook, but it helped me only partly.

For example – I want to resize/crop images on upload.
I will use a number of different forms related to different models and controllers/actions.

Obviously I need to write a class with scale, resize, saveImage and other helpful methods.
I also need the ability to use this methods from different places.

My question is – where is the right place to put this code? And can someone provide me some simple examples about core difference between component, utility and behavior? Because for me components and utilities looks very similar.

  • 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-15T16:31:46+00:00Added an answer on June 15, 2026 at 4:31 pm
    • Behaviors are packages of logic that apply to Models.
    • Components are packages of logic that apply to Controllers.
    • Utilities are general libraries that don’t necessarily apply to any one specific part of MVC.

    The major difference between Utilities and Behaviors/Components is that Utility classes don’t extend a core MVC class, and thus don’t automatically receive hooks into their parent class’s request cycle. For example, in a Component, you could implement a beforeRender() function that would get called before the controller renders its layout/views, automatically, every time that controller gets called.

    Also, Utility classes must be instantiated and assigned to a variable before use: $myUtil = new MyUtility(); $myUtil->blah() — Behaviors/Components/Helpers get instantiated when they’re loaded into a class and can be referenced with $this->MyComponent->blah().

    In your case, the image manipulation logic would most likely belong in either a Component or a Utility class, and you can choose to implement it either way. Personally, I would go with writing a Component since you’re unlikely to utilize the image manipulation logic outside of your Controllers.

    Edit: You might also consider finding and using an existing component that someone has already written, for example I found ImageTool, Image Resizer, Image Upload & Resizer, and Thumbnail in about 2 minutes of Google searching.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I want to count how many characters a certain string has in PHP, but
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
This could be a duplicate question, but I have no idea what search terms
I've tracked down a weird MySQL problem to the two different ways I was

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.