PHPackages                             zkl/baidu-ai-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. zkl/baidu-ai-php

ActiveLibrary[API Development](/categories/api)

zkl/baidu-ai-php
================

baidu pulic ai php sdk

1.0(5y ago)326Apache-2.0PHPPHP &gt;=7.0.0

Since Dec 21Pushed 4y ago1 watchersCompare

[ Source](https://github.com/zklknight/baidu-ai-php-sdk)[ Packagist](https://packagist.org/packages/zkl/baidu-ai-php)[ RSS](/packages/zkl-baidu-ai-php/feed)WikiDiscussions main Synced today

READMEChangelog (1)DependenciesVersions (2)Used By (0)

百度AI开放平台 PHP SDK composer安装
===========================

[](#百度ai开放平台-php-sdk-composer安装)

百度AI开放平台 PHP SDK composer安装

百度AI sdk 文档地址使用教程和百度的文档一样,把原本的引入方式(require\_once 'AipFace.php') 改成composer的命名空间(use baidu\\ai\\AipFace)引入

composer 安装: composer require zkl/baidu-ai-php

使用示例(人脸对比):

```
    use baidu\ai\AipFace;
    use app\common\model\FaceContrastModel;
    use think\facade\Config;

    class BaiduAiFaceService
    {
        private static $config = [];

        public function __construct()
        {
            self::$config = Config::get('baidu.ai');
        }

        /**
         * 人脸对比接口
         * https://ai.baidu.com/ai-doc/FACE/zk37c1qrv#%E4%BA%BA%E8%84%B8%E5%AF%B9%E6%AF%94
         * @param string $image1 通常为手机、相机拍摄的人像图片
         * @param string $image2 证件照片：如拍摄的身份证、工卡、护照、学生证等证件图片
         * @return float
         */
        public static function getFaceContrast(string $image1, string $image2): float
        {
            $image1 = './storage/upload/my/live.jpg';
            $image2 = './storage/upload/my/card.jpg';
            $client = new AipFace(self::$config['app_id'], self::$config['api_key'], self::$config['secret_key']);
            $result = $client->match(array(
                array(
                    'image' => base64_encode(file_get_contents($image1)),
                    'image_type' => 'BASE64',
                    'face_type' => 'LIVE'
                ),
                array(
                    'image' => base64_encode(file_get_contents($image2)),
                    'image_type' => 'BASE64',
                    'face_type' => 'CERT'
                ),
            ));
            // $result = '{"error_code":0,"error_msg":"SUCCESS","log_id":3575942510189,"timestamp":1608174532,"cached":0,"result":{"score":91.55084229,"face_list":[{"face_token":"68006dd55d9b84a57532f9ae0b876f9a"},{"face_token":"cc8754354c091eb5bde8e43ae22eeee4"}]}}';
            // $result = json_decode($result,true);
            if ($result['error_code'] == 0) {
                $score = round($result['result']['score'], 2);
                //插入记录
                FaceContrastModel::insert(['live_image' => $result['result']['face_list']['0']['face_token'], 'card_image' => $result['result']['face_list']['1']['face_token'], 'sorce' => $score]);
            } else {
                $score = 0;
            }
            return $score;
        }
    }

```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1965d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f0ba548655e68c9b0f1f840d28fe97f9182ef495ac56e9a3669267369a098ae0?d=identicon)[zklknight](/maintainers/zklknight)

---

Top Contributors

[![zklknight](https://avatars.githubusercontent.com/u/26521492?v=4)](https://github.com/zklknight "zklknight (6 commits)")

### Embed Badge

![Health badge](/badges/zkl-baidu-ai-php/health.svg)

```
[![Health](https://phpackages.com/badges/zkl-baidu-ai-php/health.svg)](https://phpackages.com/packages/zkl-baidu-ai-php)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M474](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M270](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M186](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M33](/packages/facebook-php-business-sdk)[microsoft/microsoft-graph

The Microsoft Graph SDK for PHP

65723.5M95](/packages/microsoft-microsoft-graph)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
