> ## Documentation Index
> Fetch the complete documentation index at: https://plivo.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Upgrade from PHP SDK Legacy to v4.25.0 or Latest Version

> Migrate your PHP messaging app from legacy to active SDK

## Introduction

This is a major application update. Plivo recommends you always use the latest or an active version of our SDKs for guaranteed security, stability, and uptime. The active SDK versions are designed to handle intermittent and regional failures of API requests. In addition, they offer a host of security features, such as protection against DoS attacks and bot detection for suspicious user agents.

<Warning>
  <p><strong>Deprecation notice:</strong> We’re deprecating Plivo PHP SDK legacy versions lower than 4.25.0 on January 31, 2022. If you use a deprecated version of our SDK after that date, your API requests and messaging may fail intermittently. Plivo will no longer provide bug fixes to these versions, and our support team may ask you to upgrade before debugging issues.</p>
</Warning>

## Migrate your applications

### PHP version support

The 4.x version of the Plivo SDK is compatible with PHP versions 7.3 and higher.

Use the command `composer require plivo/plivo-php:4.25.0` to upgrade to the active version of the SDK, or `composer require plivo/plivo-php` to upgrade to the latest version.

After you upgrade to the latest version of the SDK, you should check every program that depends on it and make changes to the syntax for several kinds of operations. Here are examples of how coding differs between the deprecated legacy version of the SDK and the latest active versions.

### Import the SDK

<table>
  <tr>
    <td>
      **Legacy**
    </td>

    <td>
      **Latest**
    </td>
  </tr>

  <tr>
    <td>
      <div>
        ```php theme={null}
        <?php
        require 'vendor/autoload.php';
        use Plivo\RestAPI;
        ```
      </div>
    </td>

    <td>
      <div>
        ```php theme={null}
        <?php
        require 'vendor/autoload.php';
        use Plivo\RestClient;
        ```
      </div>
    </td>
  </tr>
</table>

### Initialize

<table>
  <tr>
    <td>
      **Legacy**
    </td>

    <td>
      **Latest**
    </td>
  </tr>

  <tr>
    <td>
      <div>
        ```php theme={null}
        $p = new RestAPI($auth_id, $auth_token);
        ```
      </div>
    </td>

    <td>
      <div>
        ```php theme={null}
        $client = new RestClient("<auth_id>","<auth_token>");
        ```
      </div>
    </td>
  </tr>
</table>

### Access resources

<table>
  <tr>
    <td>
      **Legacy**
    </td>

    <td>
      **Latest**
    </td>
  </tr>

  <tr>
    <td>
      <div>
        ```php theme={null}
        $response = $p->send_message($params);
        ```
      </div>
    </td>

    <td>
      <div>
        ```php theme={null}
        $response = $client->messages->create($params);
        ```
      </div>
    </td>
  </tr>
</table>

### Send a message

<table>
  <tr>
    <td>
      **Legacy**
    </td>

    <td>
      **Latest**
    </td>
  </tr>

  <tr>
    <td>
      <div>
        ```php theme={null}
        <?php
            require 'vendor/autoload.php';
            use Plivo\RestAPI;
            $auth_id = '<auth_id>';
            $auth_token = '<auth_token>';

            $p = new RestAPI($auth_id, $auth_token);
            $params = array(
                'src' => '+12025551212', 
                'dst' => '+12025552323',
                'text' => 'Hello, this is a sample text',
                'url' => 'https://<yourdomain>.com/sms_status/'
            );
            $response = $p->send_message($params);
            
            echo "Response : ";
            print_r ($response['response']);
        ?>

        ```
      </div>
    </td>

    <td>
      <div>
        ```php theme={null}
        <?php
        require 'vendor/autoload.php';
        use Plivo\RestClient;

        $client = new RestClient('<auth_id>','<auth_token>');
        $response = $client->messages->create(
          [  
            "src" => "+12025551212",
            "dst" => "+12025552323",
            "text"  =>"Hello, this is a sample text",
            "url"=>"https://<yourdomain>.com/sms_status/"
         ]
        );
        print_r($response);
        ?>
        ```
      </div>
    </td>
  </tr>
</table>

### Retrieve a message

<table>
  <tr>
    <td>
      **Legacy**
    </td>

    <td>
      **Latest**
    </td>
  </tr>

  <tr>
    <td>
      <div>
        ```php theme={null}
        <?php
            require 'vendor/autoload.php';
            use Plivo\RestAPI;
            $auth_id = '<auth_id>';
            $auth_token = '<auth_token>';
            $p = new RestAPI($auth_id, $auth_token);

            $params = array('record_id' => '<your_message_uuid>');
            $response = $p->get_message($params);
            
            print_r ($response['response']);
        ?>
        ```
      </div>
    </td>

    <td>
      <div>
        ```php theme={null}
        <?php
        require 'vendor/autoload.php';
        use Plivo\RestClient;

        $client = new RestClient('<auth_id>','<auth_token>');
        $response = $client->messages->get('<your_message_uuid>');
        print_r($response);
        ?>
        ```
      </div>
    </td>
  </tr>
</table>

### List all messages

<table>
  <tr>
    <td>
      **Legacy**
    </td>

    <td>
      **Latest**
    </td>
  </tr>

  <tr>
    <td>
      <div>
        ```php theme={null}
        <?php
            require 'vendor/autoload.php';
            use Plivo\RestAPI;
            $auth_id = '<auth_id>';
            $auth_token = '<auth_token>';
            $p = new RestAPI($auth_id, $auth_token);

            $response = $p->get_messages();


            print_r ($response['response']);
            
            $params = array(
                'limit' => '5', 
                'offset' => '0',
            );
            
            $response = $p->get_messages($params);
            print_r ($response['response']);
        ?>
        ```
      </div>
    </td>

    <td>
      <div>
        ```php theme={null}
        <?php
        require 'vendor/autoload.php';
        use Plivo\RestClient;

        $client = new RestClient('<auth_id>','<auth_token>');
        $response = $client->messages->list(
          [
            'limit' => 5,
            'offset' => 0
          ]
        );
        print_r($response);
        ?>
        ```
      </div>
    </td>
  </tr>
</table>
