To use the Log Service SDK for PHP, you must first install it. This topic describes the installation process.
Prerequisites
Log Service is activated. For more information, see Activate Log Service.
You have an access key. For more information, see access key.
An Alibaba Cloud account's access key grants full permissions on all APIs, posing a high security risk. We recommend using a RAM user for API calls or routine O&M. You must grant the RAM user the required permissions to manage Log Service resources. For more information, see Create and authorize a RAM user.
A PHP development environment. For more information, visit the official website of PHP.
The Log Service SDK for PHP supports PHP 5.2.1 and later. You can run the
php -vcommand to check your installed PHP version.
Install the Log Service PHP SDK
Unzip aliyun-log-php-sdk-master.zip.
Copy the unzipped directory from step 2 to your project folder.
The Log Service SDK for PHP requires no additional installation. In addition to the SDK code, the package contains third-party dependencies and an Autoloader class to simplify its use.
You can now include the Log Service SDK in your project with require_once.
require_once realpath(dirname(__FILE__) . '/../Log_Autoload.php');
Install with Composer
You can use Composer, a dependency management tool, to include the Log Service SDK in your project.
After installing Composer, use one of the following methods to add the Log Service SDK to your project. To learn how to install Composer, visit the official website of Composer.
Use the command line
composer require alibabacloud/aliyun-log-php-sdkAdd a dependency to the composer.json file
{ "require": { "alibabacloud/aliyun-log-php-sdk": "0.6.*" } }
References
If an API call fails, an error is returned. For troubleshooting, see the API error code reference. For more information, see API error codes.
In addition to its own SDK, Log Service also supports other Alibaba Cloud SDKs. For more information about how to use Alibaba Cloud SDKs, see Log Service - SDK Center - Alibaba Cloud OpenAPI Developer Portal.
Log Service provides a command-line interface (CLI) for automated configuration. For more information, see Log Service command-line interface (CLI).