Before you can use Simple Log Service SDK for PHP to call the API operations of Simple Log Service, you must install Simple Log Service SDK for PHP. This topic describes how to install Simple Log Service SDK for PHP.
Prerequisites
Simple Log Service is activated. For more information, see Activate Simple Log Service.
An AccessKey pair is created and obtained. For more information, see AccessKey pair.
An Alibaba Cloud account has permissions to call all API operations. If you use the AccessKey pair of an Alibaba Cloud account, security risks may occur. We recommend that you create and use a RAM user to call API operations or perform routine O&M. Make sure that the RAM user is granted the permissions to perform operations on Simple Log Service resources. For more information, see Grant permissions to a RAM user.
A PHP development environment is installed. For more information, visit the official website of PHP.
Simple Log Service SDK for PHP supports PHP 5.2.1 and later versions. You can run the
php -v
command to check the version of PHP that is installed.
Install Simple Log Service SDK for PHP
Download the latest installation package of Simple Log Service SDK for PHP.
Decompress the aliyun-log-php-sdk-master.zip installation package.
Copy the directory that you obtained in Step 2 to the project folder.
You do not need to perform additional steps to install Simple Log Service SDK for PHP. Simple Log Service SDK for PHP contains SDK code, third-party dependencies, and an Autoloader class. These components help you process calls in a simplified manner.
You can run the require_once command to reference Simple Log Service SDK for PHP in the project file.
require_once realpath(dirname(__FILE__) . '/../Log_Autoload.php');
Related operations
You can use the Composer dependency manager to reference Simple Log Service SDK for PHP in the project file.
After you install Composer, you can use one of the following methods to reference Simple Log Service SDK for PHP in your project file. For more information about how to install Composer, visit the official website of Composer.
Use the Command Prompt.
composer require alibabacloud/aliyun-log-php-sdk
Use the composer.json configuration file.
{ "require": { "alibabacloud/aliyun-log-php-sdk": "0.6.*" } }
References
- If the response that is returned by Log Service contains error information after you call an API operation, the call fails. You can handle errors based on the error codes that are returned when API calls fail. For more information, see Error codes.
- Alibaba Cloud OpenAPI Explorer provides debugging capabilities, SDKs, examples, and related documents. You can use OpenAPI Explorer to debug Log Service API operations without the need to manually encapsulate or sign requests. For more information, visit OpenAPI Portal.
- Log Service provides the command-line interface (CLI) to meet the requirements for automated configurations in Log Service. For more information, see Log Service CLI.