This topic describes how to install and update the server operation SDK for PHP.

Prerequisites

MPS is activated. For more information, see Activate ApsaraVideo Media Processing.

Overview

Alibaba Cloud SDK for PHP is a development kit that enables quick access to Alibaba Cloud services. The Alibaba Cloud Client for PHP provides underlying support. We recommend that you install the SDK by using Composer. If you cannot use Composer, you can install the SDK by using a ZIP package.
Note Alibaba Cloud SDK for PHP of the latest version is different from that of the earlier version in terms of installation and usage. Read the following sections to learn more about the installation and the usage. For more information, see Alibaba Cloud SDK for PHP.

Environment requirements

  • Requirements
    • PHP 5.5.0 or later is installed.
      Note You can run the php -v command to view the current PHP version. If you need to install PHP, visit the PHP official website.
    • Composer is used and the composer dump-autoload --optimize command is run.
    • If you use a RsaKeyPair client that is supported only on the Alibaba Cloud Japan site, OpenSSL PHP is enabled.
  • Suggestions
    • cURL 7.16.2 or later is used.
    • OPcache is used.
    • Do not use Xdebug in the production environment.

Install the SDK by using Composer (Recommended)

Composer is a dependency manager for PHP. For more information about how to install Composer, configure autoloading, and follow other best practices for defining dependencies, visit the Composer page.

  1. Install dependencies.
    1. If Composer is installed on your system, run the following command in your project folder to install Alibaba Cloud SDK for PHP as a dependency: The following sample code provides an example:
      composer require alibabacloud/sdk

      After you run the code, a folder named vendor is generated in the project folder.

      If Composer is not installed, globally install Composer. For Windows users, download and run Composer-Setup.exe. The following sample code provides an example:
      curl -sS https://getcomposer.org/installer | php
      sudo mv composer.phar /usr/local/bin/composer
      Note If HTTPS is not supported, run the curl http://getcomposer.org/installer | php command. For more information, see Composer Download.
    2. Run a Composer command to install Alibaba Cloud SDK for PHP of the latest version as a dependency. The following sample code provides an example:
      composer require alibabacloud/sdk
      Note If the installation fails due to network issues, change the address of the Composer image.
  2. Add the autoloader to the PHP script. The following sample code provides an example:
    <?php
    require __DIR__ . '/vendor/autoload.php';
    Note To use Alibaba Cloud SDK for PHP in a script, include an autoloader in the script.

Install the SDK by using a ZIP package

If Composer is unavailable, you can download a ZIP package that contains all classes and dependencies. For more information about the download link, see Installation.

Download the ZIP package, decompress it in the specified directory of the project, and then include the autoloader in your script. The following sample code provides an example:
<?php
require __DIR__ . '/vendor/autoload.php';

Update the SDK

If new operations or new features of existing operations are unavailable in the current SDK version, update the SDK to the latest version. The following sample code provides an example:
php -d memory_limit=-1 composer.phar require alibabacloud/sdk