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

  • Home
  • SEARCH
  • 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 9020601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:03:42+00:00 2026-06-16T05:03:42+00:00

I am trying to use a custom class in cakephp. Initially I had created

  • 0

I am trying to use a custom class in cakephp. Initially I had created a vendor class which works fine but I can’t use other cakephp components.

To use built in components like $this->Text, I can create a custom component but the constructor requires a argument which is a json object returned from an API and I need to keep initializing in a loop

//The constructor for the class
function __construct($objValue) {
$this->messageId = $objValue['id'];

Is using a component suitable for this purpose?

  • 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-16T05:03:43+00:00Added an answer on June 16, 2026 at 5:03 am

    you don’t need to create a component here if you don’t need it in the controller scope.
    also you don’t need to make it a vendor class (which is third party stuff).

    cake offers you a way out: Libs in APP/Lib
    You can use them anywhere anytime.

    App::uses('MyClassName', 'Lib');
    $MyClass = new MyClassName();
    

    You might even want to create a package in Lib itself – e.g. “Lib/Utility”:

    App::uses('MyClassName', 'Utility');
    

    without knowing any more about what exactly this custom class does, it is difficult to be any more specific here.

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

Sidebar

Related Questions

I'm trying to use a custom class (be.myname.rssreader.util.Global) extending android.app.Application, but when I try
I'm trying to use .MemberwiseClone() on a custom class of mine, but it throws
I've created a custom class which is a subclass of CCLayer and trying to
I'm trying to use an instant of a custom class as a template parameter.
I'm trying to force an inherited class to use a custom attribute. I'm creating
I'm trying to use custom check boxes within Fancybox. They are showing up but
I'm trying to serialize a custom class that needs to use multiple elements of
I have a class mapped with NHibernate and I'm trying to use a custom
I am trying to use a priority queue (java.util.PriorityQueue) on a custom class. I
I'm trying to use a List<T> with a custom class of mine, and being

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.