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?
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/LibYou can use them anywhere anytime.
You might even want to create a package in Lib itself – e.g. “Lib/Utility”:
without knowing any more about what exactly this custom class does, it is difficult to be any more specific here.