class - Autoloading php classes not found

I'm autoloading classes in my php file, and the autoloaded can locate and require the file with no problem. However, when I then go to use the class in my code, I get the error "Class not found". I don't understand why this is occuring, as the class file can be located and required in the autoloader with no problem. Any help is appreciated

require "../square-php-sdk-master/autoload.php";

$body = new \SquareConnect\Models\CreatePaymentRequest()

Error:

Fatal error: Uncaught Error: Class 'SquareConnect\Models\CreatePaymentRequest' not found in C:\wamp64\www\testSite.test\include\order-cart.inc.php

Answer

Solution:

Check the namespace of the files being loaded by the autoloaded. Clearly, the autoloader is able to find them, but they are loaded into a namespace other than SquareConnect\Models...
You'll find the namespace at the top of the loaded file, make sure it say:

namespace SquareConnect\Models

In lots of the Square APIs, they use the namespace \Square and not \SquareConnect so that is something to check too

Answer

Solution:

You may be using a short php tag (<?) in the plug-in file instead of the regular one (<? php), and it may be disabled

<?

change to

<?php

Or namespace may not be specified in the file

<?php

namespace SquareConnect\Models

class CreatePaymentRequest(){
    ...
}

Source