Install AI Guardrails SDK for PHP and configure credentials to start calling Content Moderation APIs.
Prerequisites
Before you begin, make sure you have:
PHP 5.5 or later
Composer installed
Install the SDK
Run the following command to install AI Guardrails SDK for PHP:
composer require alibabacloud/greenAlternatively, download the SDK source directly from GitHub.
Add the following
usedeclaration at the top of your PHP file to import the SDK namespace:use AlibabaCloud\Green\Green;
Configure environment variables
AI Guardrails SDK for PHP reads your AccessKey credentials from environment variables. Set ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET before running SDK code — this keeps credentials out of your source files.
macOS and Linux
export ALIBABA_CLOUD_ACCESS_KEY_ID=<your-access-key-id>
export ALIBABA_CLOUD_ACCESS_KEY_SECRET=<your-access-key-secret>To persist these variables across sessions, add the two export lines to your ~/.bashrc or ~/.zshrc file.
Windows (Command Prompt)
setx ALIBABA_CLOUD_ACCESS_KEY_ID <your-access-key-id>
setx ALIBABA_CLOUD_ACCESS_KEY_SECRET <your-access-key-secret>Replace <your-access-key-id> and <your-access-key-secret> with your actual AccessKey ID and AccessKey secret. For instructions on creating an AccessKey pair, see Configure credentials.
Next steps
Review the SDK sample code to make your first API call.
Explore the Content Moderation API reference for available operations.