An introduction to setting up a Square PHP SDK project.
SDKs and Samples

Set up your Square SDK for a PHP Project

Learn the basic steps to set up the Square SDK for a PHP project.

If you are new to developing Square integrations using the Square PHP SDK, you should try the Quickstart. It provides step-by-step instructions to explore your first project.

With the Square PHP SDK, you can use Composer for dependency management or configure and manage your project manually. The following are general guidelines for creating a new PHP project.

You should use Composer to configure and install the Square PHP SDK. You can get started quickly as follows:

This command does the following:

  • Searches the Packagist repository for the square/square package. PHP package names consist of a vendor name and a project name, separated by a slash.

  • Downloads the package to the vendor subdirectory.

  • Updates the composer.json file, which describes the packages and version numbers that your code uses at runtime. If composer.json does not exist, Composer creates it automatically.

After you have installed the Square PHP SDK, you can begin writing your application code.

If you prefer not to use Composer, you need to manually install and configure the Square PHP SDK. To do this, you must first clone these PHP source code packages from GitHub:

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:

https://github.com/square/square-php-sdk/blob/master/example-autoload.php

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:

If you need more assistance, contact Developer Support or ask for help in the Developer Forums.