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 -vcommand 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.
- PHP 5.5.0 or later.
- Recommendations
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.
- Install dependencies.
- 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/sdkThis 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.lockIf 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/composerNote If your system does not support HTTPS, you can usecurl http://getcomposer.org/installer | php. For additional installation instructions, see Composer Download. - The
requirecommand installs the Alibaba Cloud SDK for PHP and adds it to your project as a dependency:composer require alibabacloud/sdkNote If the installation fails due to network issues, try switching to a different Composer mirror address.
- If Composer is installed, run the following command in your project folder to add the Alibaba Cloud SDK for PHP as a dependency:
- 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该文章对您有帮助吗?