All Products
Search
Document Center

Alibaba Cloud SDK:FAQ about SDK for PHP

Last Updated:Aug 19, 2025

This topic provides answers to some frequently asked questions about the integration and use of Alibaba Cloud SDK for PHP to help you improve your development efficiency.

Environment check

  • PHP 5.6 or later is installed.

  • Composer is globally installed. For more information, see the "Globally" section of the Getting Started topic.

Important

The version of PHP used to install Alibaba Cloud SDK using Composer must be earlier than or equal to the version of PHP used to run Alibaba Cloud SDK. For example, the vendor folder generated after Alibaba Cloud SDK is installed in PHP 7.2 can be used only in PHP 7.2 or later. If the vendor folder is copied to PHP 5.6, the dependency is incompatible with PHP 5.6.

List of problems

Question 1: How do I handle AccessKey errors?

Problem: The following error message is returned after running code. The error message indicates that the AccessKey pair is not correctly configured.

  • Alibaba Cloud SDK V2.0: AlibabaCloud\Tea\Exception\TeaUnableRetryError: code: 400, AccessKeyId is mandatory for this action.

  • Alibaba Cloud SDK V1.0: Fatal error: Uncaught AlibabaCloud\Client\Exception\ClientException: AccessKey ID cannot be empty in XXX.

Solutions:

  1. Run the following commands to check whether the ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variables are configured.

    Linux/macOS

    echo $ALIBABA_CLOUD_ACCESS_KEY_ID
    echo $ALIBABA_CLOUD_ACCESS_KEY_SECRET

    Windows

    echo %ALIBABA_CLOUD_ACCESS_KEY_ID%
    echo %ALIBABA_CLOUD_ACCESS_KEY_SECRET%

    If a valid AccessKey pair is returned, the environment variables are properly configured. If no AccessKey pair or an invalid AccessKey pair is returned, configure the environment variables as required. For more information, see Configure environment variables in Linux, macOS, and Windows.

  2. Check for errors related to the AccessKey pair in the code.

    Sample error request:

    $config = new Config([
        "accessKeyId" => getenv("yourAccessKeyID"),
        "accessKeySecret" => getenv("yourAccessKeySecret")
    ]);

    Sample success request:

    $config = new Config([
        "accessKeyId" => getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"),
        "accessKeySecret" => getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET")
    ]);
    Note

    getenv("ALIBABA_CLOUD_ACCESS_KEY_ID")

    and getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET") specify that the AccessKey ID and AccessKey secret are obtained from the ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variables.

    Important

    To prevent security risks, do not write the AccessKey pair in the online code.

Question 2: What do I do if the "cURL error 60: SSL certificate problem: unable to get local issuer certificate" or "curl error 28 while downloading https://repo.packagist.org/packages.json: SSL connection timeout" error message is returned when I call an API operation?

Possible causes:

  1. Network issues: The on-premises network is unstable or the SSL connection is blocked by the firewall.

  2. Proxy issues: Access to external resources fails due to incorrect proxy configurations.

  3. SSL certificate issues: The connection times out because some SSL certificates are not trusted by the operating system of the on-premises machine.

Solutions:

  1. Make sure that you can access the Internet over stable connections.

  2. Configure PHP Composer to use a proxy:

    composer config -g -- unset http-proxy
    composer config -g -- unset https-proxy
    composer config -g http-proxy http://your-proxy:port
    composer config -g https-proxy https://your-proxy:port
  3. Download an SSL certificate issued by a trusted certificate authority (CA):

    1. Download an SSL certificate from a trusted CA. For example, you can download an SSL certificate from Mozilla. For more information, see CA certificates extracted from Mozilla.

    2. Configure the path of the SSL certificate for PHP. Search for the curl.cainfo parameter in the php.ini file, set the value of this parameter to the absolute path of the CA certificate, and then remove the semicolon (;) before the parameter.

    3. Restart the PHP service.

  4. Optional. Configure your operating system to trust the self-signed certificate. If the connection issue is caused by the self-signed certificate, allow PHP Composer to ignore SSL authentication. However, we recommend that you do not use this method in the production environment.

    composer config --global -- disable-ssl
    Important

    This command temporarily disables SSL authentication. To ensure system security, you must run the composer config --global -- enable-ssl command in the subsequent operations to enable SSL authentication again.

Question 3: What do I do if the "PHP Fatal error: Class 'Darabonba\OpenApi\Models\Config' not found" error message is returned?

The autoload feature of Composer is not enabled. Solutions:

When Composer downloads a dependency, Composer generates the vendor folder that contains the autoload.php file. Add the require_once statement to your code.

require_once(<autoload.php file in the vendor folder>)

Question 4: What do I do if the "PHP Fatal error: Uncaught exception 'GuzzleHttp\Exception\RequestException' with message 'cURL error 3" error message is returned?

The region ID or endpoint is not properly configured. Solutions:

Make sure that the service that you want to access is available in the selected region. In this example, Short Message Service (SMS) is used. You can go to the homepage of SMS in OpenAPI Explorer and view the endpoints of SMS in various regions.image

Question 5: What do I do if the "Could not fetch [repository], please review your configured GitHub OAuth token" error message is returned?

The GitHub OAuth token provided to Composer is incorrect or has expired. Solutions:

Important

You do not need to configure a GitHub OAuth token for the Alibaba Cloud SDK package.

  • If your Composer is not installed from the official website and no GitHub OAuth token is required to access a private repository, remove the auth.json file from the Composer directory.

  • If a GitHub OAuth token is required to access a private repository, follow the instructions in Composer to update the token.

Question 6: What do I do if the "cURL error 28: Resolving timed out after 5000 milliseconds (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://dysmsapi.aliyuncs.com" error message is returned when I call an API operation?

An API call timeout may be caused by multiple factors. The following section describes the common causes and the corresponding solutions.

Network connection issues

Cause: The request cannot reach the server because the network connection between the client and server fails or the network is unstable.

Solutions:

Run the ping or curl command to test the connectivity between the on-premises host and the endpoint of the cloud service. For example, run the ping dysmsapi.aliyuncs.com or curl -v https://dysmsapi.aliyuncs.com command to test the connectivity between your on-premises host and the endpoint of the SMS API.

  • If the command times out or does not receive a response, check for blocking policies on your on-premises firewall or routers.

  • If a response is returned, we recommend that you specify a proper timeout period to prevent request failures caused by improper timeout configurations. For more information, see Configure a timeout period. Sample code:

// Specify a timeout period using runtime parameters. The timeout period takes effect only on the requests that use the RuntimeOptions instance.
$runtimeOptions = new RuntimeOptions();
$runtimeOptions->connectTimeout = $connectionTimeoutMillis;

Long processing time of the API request

Cause: The time for processing the API request exceeds the specified read timeout period.

Solution: Specify a longer read timeout period for the API response. For more information, see Configure a timeout period. For example, you can configure the read timeout parameter to extend the read timeout period. Sample code:

// Configure the timeout period for read requests using runtime parameters. The timeout period takes effect only for requests that use RuntimeOptions.
$runtimeOptions = new RuntimeOptions();
$runtimeOptions->readTimeout = $readTimeoutMillis;

Question 7: What do I do if the "alibabacloud/tea[3.0.0,3.2.01 require ext-curl*-> it is missing from your system. Install or enable PHP's curl extension,100e..." error message is returned?

The cURL plug-in for PHP is not installed. Solutions:

For Ubuntu or Debian systems:

sudo apt-get install php-curl

For CentOS, Fedora, and RHEL systems:

sudo yum install php-curl

Question 9: What do I do if the "[Composer\Downloader\TransportException], failed to download the file due to HTTP/1.1 404 Not Found" or "“your requirements could not be resolved to an installable set of packages" error is thrown by the composer require command?

image

Possible causes:

  • The image source, such an Alibaba Cloud image, is not synchronized with the latest package. As a result, some required files are absent.

  • The URL of the image source may have changed, or the path is incorrect.

Solutions:

  1. Make sure that the image source is correct.

    1. Run the following command to check the image source configured for PHP Composer:

      composer config -g --list
    2. Alibaba Cloud images for Composer: https://mirrors.aliyun.com/composer/

      composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
    3. Tsinghua University TUNA Association images for Composer: https://mirrors.tuna.tsinghua.edu.cn/composer/

      composer config -g repo.packagist composer https://mirrors.tuna.tsinghua.edu.cn/composer/
  2. Temporarily disable the image source and use the Composer image repository. Modify or delete the repositories configuration in the composer.json file, or run the composer config --unset repos.url command.

    # Use the Composer image repository. 
    composer config -g repo.packagist composer https://packagist.org
  3. Check the network connection. Unstable network connections may cause file download errors. Switch to another network environment or use a VPN.

  4. Optional. When you run the command, if the Warning: This development build of composer is over 60 days old. It is recommended to update it by running "/usr/bin/composer self-update" to get the latest version error message is returned, your PHP Composer is outdated. We recommend that you update Composer to the latest version and run Composer again.

    # Update Composer to the latest version. 
    composer self-update
    # Use the composer.phar file to run the latest version. 
    composer self-update --1
  5. If a Composer warning is output when you run the command, support for Composer 1 will be disabled. Optional. To ensure compatibility and security, we recommend that you update Composer to version 2.X.

    composer self-update --2
    Important

    Check whether the dependency package of the project supports Composer 2.x. Update the project code and configurations if necessary.

  6. If the Content-Length error is thrown during the download process, data downloading may be interrupted. The received data is different from the expected data.

    1. Clear the Composer cache and run the command again to install Composer.

      # Delete the .composer directory.
      Remove-Item -Recurse -Force $HOME\.composer
      
      # Delete all content in the /tmp directory.
      Remove-Item -Recurse -Force C:\tmp\*
      rm -rf ~/.composer/ && rm -rf /tmp/*
    2. Unstable network connections may interrupt data downloading. You can run the command multiple times to ensure that Composer is installed.

    3. Make sure that network connections are stable and download the file during off-peak hours.

Question 10: What do I do if the "Could not delete D:\www\touming_keyword_api\vendor\composer\tmp-7fd77eb46d69640d6040743642007957:This can be due to an antivirus or the Windows Search Indexer locking the file while they are analyzed." error is thrown by PHP Composer?

image

Possible causes:

When Composer attempts to install the dependency, the temporary file cannot be deleted because the file is locked by some anti-virus software or Windows Search Indexer.

Solutions:

  1. Check whether you have sufficient permissions on the Windows operating system. If not, Composer may fail to create or modify the required files.

    1. Run all Composer commands as the administrator to prevent permission issues.

    2. Make sure that Composer has read and write permissions on the required files and directories.

  2. Make sure that the package version is available, clear the cache, and re-install the dependency.

    1. Query the available versions of the package. Sample command:

      composer show alibabacloud/ecs-20140526 --all
    2. Clear the Composer cache and re-install the dependency:

      composer clear-cache
  3. Check whether Windows Search Indexer is running as expected. This service may index files, which locks the files. To stop this service, perform the following steps:

    1. Press the Win and R keys to open the Run program.

    2. Enter services.msc and press the Enter keys.

    3. Find the Windows Search service, right-click the service, and then select Stop.

    4. After you stop Windows Search, install the Composer dependency again.

  4. Unlock the files or create a directory for installing the dependency.

    1. To unlock the files, run the following commands as the administrator:

      1. Right-click Command Prompt or PowerShell and select Run as administrator.

      2. Run the following command to delete the locked directory:

        rmdir /S /Q "D:\www\touming_keyword_api\vendor\composer\tmp-7fd77eb46d69640d6040743642007957"
      3. Make sure that the file is not locked by a program, such as anti-virus software or Windows Search Indexer. You can temporarily disable your anti-virus software and run the Composer command.

    2. Create a directory for installing the dependency. In the directory, perform the following Composer operations:

      mkdir D:\new_directory
      cd D:\new_directory
      composer require alibabacloud/ecs-20140526 6.0.1
  5. If the 404 error is thrown during the installation process, switch to another image source and perform the installation again.

    composer config -g repo.packagist composer https://packagist.org

Question 11: What do I do if the "cURL error 61" error is thrown by the composer require alibabacloud/dysmsapi-20170525 command?image

Possible causes:

  1. Composer cache issues: The local cache is damaged or incomplete.

  2. Image source issues: The image source is unstable or unavailable.

  3. Network issues: The network connections are unstable or blocked by the firewall.

  4. Composer version issues: Composer is outdated.

  5. Environment configuration issues: The environment variables or Composer configuration file contain errors.

Solutions:

  1. Check the network connection.

    1. Run the following command to test the network connectivity:

      curl -I https://mirrors.aliyun.com/composer/p2/alibabacloud/dysmsapi-20170525.json
    2. You can check the firewall settings to ensure that the firewall is not blocking curl from accessing external resources.

    3. Switch to another network or network environment, such as from the office network to a personal network.

  2. Configure Composer to use the Composer image repository.

    composer config -g --list
    composer config -g repo.packagist composer https://packagist.org
  3. Delete the Composer package, re-install Composer, and clear the Composer cache.

    1. Delete the on-premises cache directory:

      rm -rf ~/.composer
    2. Clear the Composer cache:

      composer clear-cache
  4. If the issue persists, check the detailed Composer logs:

    composer install --verbose

Question 12: The "Your requirements could not be resolved to an installable set of packages." error occurs when you use composer to install an Alibaba Cloud SDK package.

This error can occur for various reasons. The following examples can help you resolve this error.

Example 1

Error message:

Your requirements could not be resolved to an installable set of packages.

Problem 1
 - Root composer.json requires alibabacloud/cloudauth-20190307 3.4.1, found alibabacloud/cloudauth-20190307[dev-master, 1.0.0, ..., 1.0.7, 2.0.0, ..., 2.9.1, 3.0.0, ..., 3.3.0] but it does not match the constraint.
Installation failed, reverting ./composer.json and ./composer.lock to their original content.

Possible causes:

  1. The specified version number, such as 3.4.1, may not exist or may not be released.

  2. The Composer mirror source that you are using is not synchronized with the latest version of the package.

  3. A network issue prevents the package from being pulled correctly.

Solution:

  • Run the following command to query all available package versions:

    composer show alibabacloud/XXXXXX --all

    Specify an available version in the composer.json file, and run the composer update command to update to the latest version.

  • Switch to another Composer image source.

    • Run the following command to switch to a Packagist image source:

      composer config -g repo.packagist composer https://repo.packagist.org
    • Switch to the Alibaba Cloud accelerated image source in the Chinese mainland:

      composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/

    After the switch, clear the cache and re-install the package:

    composer clear-cache
    composer install

  • Check the network connectivity and switch to a stable environment. If the error persists, manually download the .zip or .tar.gz package file and install it in a local directory.

    composer require alibabacloud/XXXXXX@dev --prefer-source

Example 2

Error message:

image

Cause:

When you install alibabacloud/cloudauth-20190307:3.9.2, its dependency alibabacloud/tea-oss-utils:0.3.1 requires guzzlehttp/psr7 version [1.0.0,...,2.0.0). However, the currently installed version of guzzlehttp/psr7 is fixed to [1.0.0,..,1.9.1]. This causes a dependency conflict.

Solution:

  • Force an update of the dependency version.

    composer require alibabacloud/cloudauth-20190307 3.9.2 -W
  • In the composer.json file, add a version constraint for guzzlehttp/psr7 in the require section, for example, "guzzlehttp/psr7": "^1.0". Then, run the following command to update the dependency.

    composer update
  • Delete composer.lock and run the following command to reinstall the dependencies.

    composer install --prefer-source

Question 12: What do I do if the "cURL error 60: SSL certificate problem: unable to get local issuer certificate" error message is returned when I call an API operation?

Causes:

  1. The CA certificate package is not downloaded. The system lacks a trusted CA certificate file. As a result, cURL cannot verify the SSL certificate.

  2. No CA certificate path is specified in the PHP cURL configurations. The curl.cainfo or openssl.cafile parameter is not correctly configured in the php.ini file.

  3. The PHP service is disabled: The PHP service is not enabled after the php.ini file is modified. In this case, the configurations do not take effect.

Solutions:

  1. Download an SSL certificate from a trusted CA. For example, you can download an SSL certificate from Mozilla. For more information, see CA certificates extracted from Mozilla. Store the cacert.pem file in a fixed directory.

    Important

    Make sure that the file path does not contain Chinese characters or special characters. Otherwise, issues may arise.

  2. Configure the path of the SSL certificate for PHP.

    • Open the PHP configuration file php.ini. You can run the php --ini command to query the location of the file.

    • In the php.ini file, find curl.cainfo, set its value to the absolute path of the CA certificate, and remove the leading ; from the configuration item.

      # Example
      curl.cainfo = "D:\path\to\cacert.pem"
      openssl.cafile = "D:\path\to\cacert.pem"

      Save the file after you make the modifications.

      Note

      Replace the D:\path\to\cacert.pem path in the example with the absolute path of your CA certificate.

  3. Restart the PHP service.

Question 13: What do I do if the "the package is fixed to version 1.0.3 (lock file version)" or "ralouphie/mimey 2.1.0 requires php ^5.4|^7.0 your php version (8.2.27) does not satisfy that requirement" error message is returned when I fail to install Composer?

Causes:

  1. Version conflicts:

    • Some dependencies are locked to a specific version by the composer.lock file.

    • By default, Composer does not automatically update the dependency packages that are locked to a specific version.

    • For example, alibabacloud/cloudauth-20190307 requires version 2.0.1 of alibabacloud/openplatform-20191219, which is locked to version 1.0.3.

  2. Incompatibility with the PHP version:

    • PHP 8.2 is used but some dependency packages support only PHP 5.4 to PHP 7.X.

    • For example, ralouphie/mimey 2.1.0 supports only PHP ^5.4|^7.0, but your environment uses PHP 8.2.27.

Solutions:

  1. Forcibly upgrade the version of all dependency packages:

    composer update --with-all-dependencies
    # Simplified command:
    composer update -W
    Note

    This command upgrades all dependency packages, including the dependency packages that are locked to a specific version by the composer.lock file. This resolves version conflicts.

  2. Clear the composer.lock and vendor/ files and re-install the packages. This method is applicable to scenarios that contain severe dependency chaos.

    rm composer.lock vendor/
    composer clear-cache
    composer install
    Important

    This operation removes all installed dependencies.

  3. If a dependency package does not support PHP 8, temporarily downgrade to an earlier PHP version to maintain compatibility.

Question 14: What do I do if the "Script @php think service:discover handling the post-autoload-dump event returned with error code 255" error message is returned?

Causes:

  • After you run the composer install or update command, Composer attempts to run the php think service:discover command of ThinkPHP to automatically discover services but failed. As a result, the entire installation process is interrupted.

  • Out of memory (OOM) or other issues.

Solutions:

  1. Temporarily disable the service discovery script and modify the composer.json file in the root directory.

    {
        "scripts": {
            "post-autoload-dump": "@php think service:discover"
        }
    }

    Change to:

    {
        "scripts": {
            "post-autoload-dump": "@echo Skipping 'php think service:discover'"
        }
    }

    Run the composer dump-autoload command again.

  2. Add a PHP memory limit by adding the following configuration to the php.ini file:

    memory_limit = 512M

Question 15: The "Undefined property: Darabonba\OpenApi\Models\Config::$tlsMinVersion" error occurs

Cause: The version of alibabacloud/darabonba-openapi is earlier than 0.2.14.

Solution: Run the following command to update the version of alibabacloud/darabonba-openapi to 0.2.14 or later.

composer require alibabacloud/darabonba-openapi >=0.2.14 

Technical support

The solutions to the preceding issues can help you better use Alibaba Cloud SDKs. If you encounter other issues when you use Alibaba Cloud SDKs, contact us in the following way:

  • Submit a ticket.

  • If you have questions or feedback, join the DingTalk group (ID: 60965016010) for technical support.