When you setup the SDK did you bring in all the dependencies as outlined in the manual setup. To do this, you must first clone these PHP source code packages from GitHub:
- square/square-php-sdk. The Square PHP SDK.
- apimatic/jsonmapper. A library that dynamically converts JSON responses from Square APIs into PHP classes.
- apimatic/unirest-php. A RESTful HTTP client that works with Square APIs.
Next, you need to provide an autoload script (autoload.php) so that your application can easily access the PHP source code packages at runtime. The Square PHP SDK provides the following example autoload script:
You can download this file, rename it to autoload.php, and use it as is. You can also customize the script to suit your needs.
In your application code, add a require
statement to run the autoload script. After that, you are able to use
any of the Square PHP SDK classes. For example:
1
2
3
require 'autoload.php';
use Square\SquareClient;