PHPackages                             panyongwei/easysdk-alipay-kernel - 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. panyongwei/easysdk-alipay-kernel

ActiveLibrary[API Development](/categories/api)

panyongwei/easysdk-alipay-kernel
================================

EasySDK支付宝核心库

v0.0.1(4y ago)3101PHPPHP &gt;=7.2.5

Since Sep 9Pushed 4y ago1 watchersCompare

[ Source](https://github.com/panyongwei/easysdk-alipay-kernel)[ Packagist](https://packagist.org/packages/panyongwei/easysdk-alipay-kernel)[ RSS](/packages/panyongwei-easysdk-alipay-kernel/feed)WikiDiscussions main Synced yesterday

READMEChangelogDependencies (2)Versions (2)Used By (0)

前言
--

[](#前言)

工作这些年接入过很多次大厂的API，使用过程中终会遇到点奇奇怪怪的问题。

在阅读了市面上现有的很多SDK源码之后给我一个启发，我想让更多大厂难用的API变得更简单易用。

于是EasySdk就在这样的设想下横空出世了，这是EasySdk支付宝的核心库，分开各个大分类的分支，各位同学可以直接fork本仓库实现自己的SDK。

QQ交流群：57914282

特点
--

[](#特点)

- 简单易用使用
- 隐藏开发者不需要关注的细节
- 支持开发者替换自己的模块

运行环境
----

[](#运行环境)

- PHP 7.2.5+
- composer

依赖库
---

[](#依赖库)

- "pimple/pimple": "^3.4"
- "guzzlehttp/guzzle": "^7.3"
- "ext-mbstring": "\*"

安装
--

[](#安装)

```
composer require panyongwei/easysdk-alipay-kernel:~0.0.1 -vvv
```

基于 easysdk-alipay-kernel 开发自己的类库
--------------------------------

[](#基于-easysdk-alipay-kernel-开发自己的类库)

### 1、修改 composer.json 文件家在支付宝核心库

[](#1修改-composerjson-文件家在支付宝核心库)

```
"require": {
  "sphynx/easysdk-alipay-kernel": "dev-master"
},
```

### 2、库目录

[](#2库目录)

```
├── composer.json                   composer.json管理
├── src                             库源码
    ├── AlipayPay.php               入口文件通过这个文件去 Application.php 注册服务和调用
    ├── Application.php             服务提供者文件，负责注册和调用不同模块的服务对象
    ├── F2fpay                      面对面支付实例
        ├── Client.php              面对面支付api对接代码，开发者都在这里编写业务逻辑
        └── ServiceProvider.php     面对面支付宝服务提供者注册代码
└── vendor

```

#### AlipayPay.php 代码

[](#alipaypayphp-代码)

```
namespace EasySDK\AlipayPay;
use EasySDK\AlipayKernel\ServiceContainer;
/**
 * @method static Application Foctory(array $config)
 */
class AlipayPay extends ServiceContainer
{
    public static function make(string $name, array $config)
    {
        // 这里的命名空间是 Application.php 所在的命名空间
        $application = "\\EasySDK\\AlipayPay\\Application";
        return new $application($config);
    }

    public static function __callStatic($name, $arguments)
    {
        return self::make($name, ...$arguments);
    }
}
```

#### Application.php 代码

[](#applicationphp-代码)

```
namespace EasySDK\AlipayPay;
use EasySDK\AlipayKernel\ServiceContainer;
/**
 * @property \EasySDK\AlipayPay\F2fpay\Client $f2fpay 付款码支付
 * @property \EasySDK\AlipayPay\Pc\Client $pc 电脑网站支付
 */
class Application extends ServiceContainer
{
    /**
     * 服务注册
     */
    protected array $providers = [
        \EasySDK\AlipayPay\F2fpay\ServiceProvider::class,
        \EasySDK\AlipayPay\Pc\ServiceProvider::class,
    ];

    /**
     * @param string $name
     * @param array $arguments
     *
     * @return mixed
     */
    public function __call(string $name, array $arguments)
    {
        return call_user_func_array([$this['base'], $name], $arguments);
    }
}
```

#### F2fpay/Client.php 代码

[](#f2fpayclientphp-代码)

```
namespace EasySDK\AlipayPay\F2fpay;
use EasySDK\AlipayKernel\Exceptions\InvalidArgumentException;
use EasySDK\AlipayKernel\Exceptions\InvalidSignException;
use EasySDK\AlipayKernel\Exceptions\NetworkException;
use EasySDK\AlipayKernel\BaseClient;

class Client extends BaseClient
{
    /**
     * 面对面付款下单接口功能
     * 统一收单交易支付接口
     * 参数参考：https://opendocs.alipay.com/apis/api_1/alipay.trade.precreate
     * @param array $params
     * @return mixed
     * @throws InvalidArgumentException
     * @throws InvalidSignException
     * @throws NetworkException
     */
    public function precreate(array $params): mixed
    {
        $method = "alipay.trade.precreate";
        return $this->post($method, $params);
    }
}
```

$params 参数是支付宝的请求参数数组，调用 BaseClient 里面的 post 方法即可，签名和验签都已经在 BaseClient 实现。

QQ交流群：57914282

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 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

1705d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0a8ce8931103bacaff0f21db339886fab070370c7c4876bc638887eaeded0e99?d=identicon)[sphynx](/maintainers/sphynx)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/panyongwei-easysdk-alipay-kernel/health.svg)

```
[![Health](https://phpackages.com/badges/panyongwei-easysdk-alipay-kernel/health.svg)](https://phpackages.com/packages/panyongwei-easysdk-alipay-kernel)
```

###  Alternatives

[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[convertkit/convertkitapi

Kit PHP SDK for the Kit API

2167.1k1](/packages/convertkit-convertkitapi)[mapado/rest-client-sdk

Rest Client SDK for hydra API

1125.9k2](/packages/mapado-rest-client-sdk)

PHPackages © 2026

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