# Use php class file in controller

**URL:** <https://discourse.cakephp.org/t/use-php-class-file-in-controller/9186>\
**Category:** Need Help\
**Created:** [March 30, 2021, 7:33am UTC](https://discourse.cakephp.org/t/use-php-class-file-in-controller/9186 "2021-03-30T07:33:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rsuyambu](https://avatars.discourse-cdn.com/v4/letter/r/a3d4f5/32.png) [@rsuyambu](https://discourse.cakephp.org/u/rsuyambu)\
**Post date:** [March 30, 2021, 7:33am UTC](https://discourse.cakephp.org/t/use-php-class-file-in-controller/9186/1 "2021-03-30T07:33:53Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![dirk](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/dirk/32/2174_2.png) [@dirk](https://discourse.cakephp.org/u/dirk)\
**Post date:** [March 30, 2021, 11:33am UTC](https://discourse.cakephp.org/t/use-php-class-file-in-controller/9186/2 "2021-03-30T11:33:29Z")

</div>

Maybe this could help:  
[https://book.cakephp.org/4/en/core-libraries/app.html#loading-vendor-files](https://book.cakephp.org/4/en/core-libraries/app.html#loading-vendor-files)

---

<div class="post-metadata">

**Author:** ![alex](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/alex/32/2375_2.png) [@alex](https://discourse.cakephp.org/u/alex)\
**Post date:** [March 31, 2021, 5:59am UTC](https://discourse.cakephp.org/t/use-php-class-file-in-controller/9186/3 "2021-03-31T05:59:27Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Jawfin](https://avatars.discourse-cdn.com/v4/letter/j/dbc845/32.png) [@Jawfin](https://discourse.cakephp.org/u/Jawfin)\
**Post date:** [March 31, 2021, 2:07pm UTC](https://discourse.cakephp.org/t/use-php-class-file-in-controller/9186/4 "2021-03-31T14:07:33Z")

</div>

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++](https://notepad-plus-plus.org/downloads/)

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.

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [March 31, 2021, 2:41pm UTC](https://discourse.cakephp.org/t/use-php-class-file-in-controller/9186/5 "2021-03-31T14:41:09Z")

</div>

I think Unicode 0027 is actually an [apostrophe](https://www.fileformat.info/info/unicode/char/0027/index.htm). 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.
