Install the SDK Package
Updated at:2025-11-03
Runtime environment
The PHP SDK requires a minimum PHP version of 5.3.2, such as versions 5.4, 5.5, 5.6, 7.0, 7.1, 7.2, 7.3, or 8.0.
Note:
- SDK versions 0.9.19 and above are applicable to PHP 7.3 and higher versions
- If you don’t need to use PHP 8, you can use SDK versions 0.9.18 and below
- If you encounter compatibility issues in the running environment of PHP 8.0 or above, please Submit a Work Order
Install SDK
- Download the BOS PHP SDK toolkit (ZIP package) from the Official Website.
-
After the ZIP package is decompressed, there are three files as follows:
Plain Text1BaiduBce.phar //PHP SDK 2 BosClientSample.php //Example 3 SampleConf.php //Reference configuration file, see specific content belowNote: After users configure AK/SK and Host, they can use
phpunit --debug BosClientSample.phpto run the Sample. -
Add the following code in the script file to use the SDK:
PHP1include 'BaiduBce.phar'; 2require 'YourConf.php';
For the reference of the configuration file, please refer to [Configure BosClient](BOS/SDK/PHP-SDK/Initialization.md#Configure BosClient) in the following text.
SDK directory structure
Plain Text
1BaiduBce.phar
2├──src
3│ └── BaiduBce
4 │ ├── Auth //BCE signature
5 │ ├── Exception //BCE client exception
6 │ ├── Http //BCE HTTP communication
7 │ ├── Log //BCE log
8│ ├── Services
9 │ │ └── Bos //BOS main directory, which must be retained
10 │ │ ├── BosClient.php //BOS operation class. All operations can be completed via BosClient class
11 │ │ ├── BosOptions.php //BOS custom configuration
12 │ │ └── CannedAcl.php //CannedAcl module
13 │ └── Util //BCE common utilities
14 └──vendor //Third-party libraries
Uninstall SDK
To uninstall the SDK, delete the phar package used in the script.
