PHPackages                             softlayer/softlayer-api-php-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. softlayer/softlayer-api-php-client

ActiveLibrary

softlayer/softlayer-api-php-client
==================================

SoftLayer API PHP client

v2.0.0(3y ago)4481.9k↓19.6%20[11 issues](https://github.com/softlayer/softlayer-api-php-client/issues)MITPHPPHP &gt;=8.0

Since Sep 10Pushed 3y ago17 watchersCompare

[ Source](https://github.com/softlayer/softlayer-api-php-client)[ Packagist](https://packagist.org/packages/softlayer/softlayer-api-php-client)[ Docs](https://sldn.softlayer.com/php/)[ RSS](/packages/softlayer-softlayer-api-php-client/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (2)Versions (5)Used By (0)

A SoftLayer API PHP client.
===========================

[](#a-softlayer-api-php-client)

[![Build Status](https://github.com/softlayer/softlayer-api-php-client/actions/workflows/test.yml/badge.svg)](https://github.com/softlayer/softlayer-api-php-client/actions/workflows/test.yml/badge.svg)

Warning
-------

[](#warning)

Use [v1.2.0](https://github.com/softlayer/softlayer-api-php-client/releases/tag/v1.2) for older PHP versions (php &lt; 8.0) . [v2.0.0](https://github.com/softlayer/softlayer-api-php-client/releases/tag/v2.0.0) for php 8.0 or higher.

[PHP 8.0 removed XMLRPC](https://php.watch/versions/8.0/xmlrpc) as a built in extension. As such, it is no longer required as part of the composer file in this project. The XmlRpcClient still exists here if you need it, but we assume most users are using the SoapClient. If there are any issues with this [Let us know on github](https://github.com/softlayer/softlayer-api-php-client/issues)

Overview
--------

[](#overview)

The SoftLayer API PHP client classes provide a simple method for connecting to and making calls from the SoftLayer API and provides support for many of the SoftLayer API's features. Method calls and client management are handled by the PHP SOAP and XML-RPC extensions.

Making API calls using the `\SoftLayer\SoapClient` is done in the following steps:

1. Instantiate a new `\SoftLayer\SoapClient` object using the `\SoftLayer\SoapClient::getClient()` method. Provide the name of the service that you wish to query, an optional id number of the object that you wish to instantiate, your SoftLayer API username, your SoftLayer API key, and an optional API endpoint base URL. The client classes default to connect over the public Internet.
2. Use `\SoftLayer\SoapClient::API_PRIVATE_ENDPOINT` to connect to the API over SoftLayer's private network. The system making API calls must be connected to SoftLayer's private network (eg. purchased from SoftLayer or connected via VPN) in order to use the private network API endpoints.
3. Define and add optional headers to the client, such as object masks and result limits.
4. Call the API method you wish to call as if it were local to your client object. This class throws exceptions if it's unable to execute a query, so it's best to place API method calls in try / catch statements for proper error handling.

Once your method is executed you may continue using the same client if you need to connect to the same service or define another client object if you wish to work with multiple services at once.

The most up to date version of this library can be found on the SoftLayer github public repositories:  . Any issues using this library, please open a [Github Issue](https://github.com/softlayer/softlayer-api-php-client/issues)

System Requirements
-------------------

[](#system-requirements)

The `\SoftLayer\SoapClient` class requires at least PHP 8.0.0 and the PHP SOAP enxtension installed and enabled (`extension=soap` in the php.ini file). Since [php 8.0 has removed xmlrpc extension](https://php.watch/versions/8.0/xmlrpc) you will need to manually install this library to use the `\SoftLayer\XmlRpcClient`. If you are using an earlier version of php that still includes ext-xml, please use v1.2.0 of this library.

A valid API username and key are required to call the SoftLayer API. A connection to the SoftLayer private network is required to connect to SoftLayer's private network API endpopints. See [Authenticating to the SoftLayer API](https://sldn.softlayer.com/article/authenticating-softlayer-api/) for how to get these API keys.

Installation
------------

[](#installation)

Install the SoftLayer API client using [Composer](https://getcomposer.org/).

```
composer require softlayer/softlayer-api-php-client:~2.0.0
```

Usage
-----

[](#usage)

These examples use the `\SoftLayer\SoapClient` class. If you wish to use the XML-RPC API then replace mentions of `SoapClient.class.php` with `XmlrpcClient.class.php` and `\SoftLayer\SoapClient` with `\SoftLayer\XmlRpcClient`.

Here's a simple usage example that retrieves account information by calling the [getObject()](http://sldn.softlayer.com/reference/services/SoftLayer_Account/getObject) method in the [SoftLayer\_Account](http://sldn.softlayer.com/reference/services/SoftLayer_Account) service:

```
