Use php class file in controller

I have a php uploadhandler class, I want to use this class in cakephp4 controller, Used the below line to connect the uploadhandler

Note: Created a folder UploadHandler under vendor directory and placed my class file(UploadHandler.php) in this location.

require_once(ROOT .DS. “vendor” . DS . “UploadHandler” . DS . “UploadHandler.php”);
$upload_handler = new UploadHandler($options, $initialize = false);

it’s returning the below error
“message”: “Class \u0027UploadHandler\UploadHandler\u0027 not found”,

Let me know the right way to use the classfile in cakephp4 controller?

Maybe this could help:

Judging by how it says \u0027, looks like you have a rogue unicode character in there. Turn on displaying non-printable characters in your code editor.

I reckon Alex has it right. And any assembler/machine code programmer will tell you that is the escape key. If you can’t search for ascii 27 (0x1B) try this: -

Get notepad++ Downloads | Notepad++

Open all your .php’s in it.
Edit menu, character panel.
Go to 27 and double click the word ESC in the Character column.
That will insert that character into the current document at the cursor.
Now cut that to the clipboard.
Ctrl + F for find.
Paste your ESC character, it’ll look like a square now
Click the “Find All in All Opened Documents”
And use the search results panel to hunt it down.
Remove and save!

Edit: Check Z’s post after mine for the correct solution - but if ever you can’t find a random control character (ascii value < 32) then use my approach.

I think Unicode 0027 is actually an apostrophe. Not sure why it’s formatted that way in your output, likely due to encoding it for embedding into another thing with quotes.

The actual problem you’re having here is probably one of namespaces. Dirk’s link will help with eliminating the require, and specifying the fully qualified path of the class in question should fix the error.