Installation

更新时间:
复制 MD 格式

Install and update the server-side PHP SDK for Media Processing (MPS).

Prerequisites

MPS is activated. For more information, see Activate MPS.

Overview

The Alibaba Cloud SDK for PHP provides quick access to Alibaba Cloud services and relies on Alibaba Cloud Client for PHP for core functionality. We recommend installing the SDK with Composer. You can also install it from a zip package.
Note Installation and usage of the latest SDK differ completely from previous versions. For details, see Alibaba Cloud SDK for PHP.

Environment requirements

  • Requirements
    • PHP 5.5.0 or later.
      Note Run the php -v command to check your PHP version. If PHP is not installed, download it from the PHP official website.
    • Use Composer and optimize autoloading by running composer dump-autoload --optimize.
    • If you use the RsaKeyPair client, which is supported only on the Alibaba Cloud Japan site, you must also enable the OpenSSL PHP extension.
  • Recommendations
    • Use cURL 7.16.2 or later.
    • Use OPcache.
    • Do not use Xdebug in a production environment.

Install with Composer (recommended)

Composer is a dependency management tool for PHP. For details on installing Composer, configuring autoloading, and other best practices, see the Composer documentation.

  1. Install dependencies.
    1. If Composer is installed, run the following command in your project folder to add the Alibaba Cloud SDK for PHP as a dependency:
      composer require alibabacloud/sdk
      This command creates a vendor folder in your project folder. The directory structure looks like this:
      sdkdemo02
      ├── vendor
      │   ├── adbario
      │   ├── alibabacloud
      │   ├── bin
      │   ├── clagiordano
      │   ├── composer
      │   ├── danielstjules
      │   ├── guzzlehttp
      │   ├── mtdowling
      │   ├── psr
      │   ├── ralouphie
      │   ├── symfony
      │   └── autoload.php
      ├── composer.json
      └── composer.lock
      If you do not have Composer installed, download and globally install Composer. On Windows, download and run Composer-Setup.exe. For example:
      curl -sS https://getcomposer.org/installer | php
      sudo mv composer.phar /usr/local/bin/composer
      Note If your system does not support HTTPS, you can use curl http://getcomposer.org/installer | php. For additional installation instructions, see Composer Download.
    2. The require command installs the Alibaba Cloud SDK for PHP and adds it to your project as a dependency:
      composer require alibabacloud/sdk
      Note If the installation fails due to network issues, try switching to a different Composer mirror address.
  2. Add the autoloader to your PHP script:
    <?php
    require __DIR__ . '/vendor/autoload.php';
    Note To use the Alibaba Cloud SDK for PHP in your scripts, you must include the autoloader.

Install from a zip package

If you cannot use Composer, download a zip package instead. Extract the package into your project and include the autoloader script. To download the package, see Install MPS SDK for PHP.

Include the autoload.php file in your script:
<?php
require __DIR__ . '/vendor/autoload.php';

Update the SDK

To access new API operations or features, run the following command to update the SDK to the latest version:
php -d memory_limit=-1 composer.phar require alibabacloud/sdk