PHPackages                             cblink-service/foundation - 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. cblink-service/foundation

ActiveLibrary

cblink-service/foundation
=========================

Package description here.

v1.4.4(2y ago)15.6k10MITPHPPHP &gt;=7.4

Since Dec 15Pushed 2y ago2 watchersCompare

[ Source](https://github.com/cblink-service/foundation)[ Packagist](https://packagist.org/packages/cblink-service/foundation)[ RSS](/packages/cblink-service-foundation/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (4)Versions (40)Used By (10)

 foundation-sdk
================

[](#-foundation-sdk-)

 .

安装
--

[](#安装)

```
$ composer require cblink-service/foundation -vvv
```

使用
--

[](#使用)

### 容器

[](#容器)

Container 是整个项目的核心，继承了 Pimple\\Container，也就是一个容器。你所使用的 $foundation-&gt;order $foundation-&gt;config $foundation-&gt;user 等等都是因为这个是一个容器。中含有一个 $providers 服务提供者的数组属性。

### 服务提供者

[](#服务提供者)

容器的最佳表现。接上面所说的，你可以在 Container 中注册多个服务提供者， 新建的服务提供者需要实现 Pimple\\ServiceProviderInterface，并补充完 register 方法，其实就是 new 一个类在 容器中，[参考这里](https://github.com/cblink-service/foundation/blob/master/src/Providers/ClientServiceProvider.php)

### 初始化

[](#初始化)

```
// 继承基类
class App extends \Cblink\Service\Foundation\Container {
    protected array $providers = [
        // 自定义服务提供者
        \Cblink\Service\Foundation\Providers\AccessTokenServiceProvider::class,
    ];
}

$app = new App([
    // 接口的基础请求地址
    'base_url' => '',
    // 使用 guzzle 时所需要的默认配置
    'guzzle' => [
        'timeout' => 5.0,
        'verify' => false,
    ],
])
```

### API

[](#api)

凡是写 SDK 都需要去新建一个 Api 的类，这个类需要去继承 `Cblink\Service\Foundation\BaseApi` 或 `Cblink\Service\Foundation\BaseRequestApi`。

`BaseApi`类中默认包含了实现认证的中间件，需要先将`access_token`的服务提供者引入容器中，完成在 header 中增加 Authorization已达到完成认证的目的。[参考这里](https://github.com/cblink-service/foundation/blob/master/src/AccessToken.php)如SDK中提供的认证机制不满足使用，可以自行实现 `access_token` 类，只需要将类实现 `Cblink\Service\Foundation\Contracts\AccessTokenInterface` 中的方法即可

`BaseRequestApi` 通常用于无需认证的接口。

```
# 在Api类中获取配置
class Api extends \Cblink\Service\Foundation\BaseRequestApi {

    public function getOrderLists()
    {
        // 所有的接口请求，默认为json格式返回，返回值将会转换成数组返回
       /* @var array $response */
       $response = $this->httpGet('/url', ['query' => []]);

       // post请求
       $response = $this->httpPost('/url', ['data']);

       // put 请求
       $this->httpPut();

       // delete 请求
       $this->httpDelete('/url', ['query'])
    }

    // 可以再Api中声明名为 getBaseUrl 的方法，此方法声明后将会覆盖 config 中的 base_url
    public function getBaseUrl()
    {
        return 'http://www.cblink.net';
    }
}
```

Contributing
------------

[](#contributing)

You can contribute in one of three ways:

1. File bug reports using the [issue tracker](https://github.com/cblink-service/idaas-sdk/issues).
2. Answer questions or fix bugs on the [issue tracker](https://github.com/cblink-service/idaas-sdk/issues).
3. Contribute new features or update the wiki.

*The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable.*

License
-------

[](#license)

MIT

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity62

Established project with proven stability

 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

Every ~15 days

Total

39

Last Release

1032d ago

Major Versions

v0.1.1 → v1.2.42022-08-19

v0.1.2 → v1.2.52022-08-19

v0.1.3 → v1.2.62022-08-19

0.1.4 → v1.2.72022-08-19

0.x-dev → v1.3.02023-02-22

PHP version history (2 changes)v1.0.0PHP &gt;=7.4

v1.2.0PHP &gt;=7.2.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/8a33f3d22f7c5ba81df984215eda327fe21f224f59a8a8cb404138042ec9f788?d=identicon)[overnic](/maintainers/overnic)

---

Top Contributors

[![0daynick](https://avatars.githubusercontent.com/u/17755109?v=4)](https://github.com/0daynick "0daynick (1 commits)")

### Embed Badge

![Health badge](/badges/cblink-service-foundation/health.svg)

```
[![Health](https://phpackages.com/badges/cblink-service-foundation/health.svg)](https://phpackages.com/packages/cblink-service-foundation)
```

###  Alternatives

[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[thecodingmachine/graphqlite

Write your GraphQL queries in simple to write controllers (using webonyx/graphql-php).

5723.1M30](/packages/thecodingmachine-graphqlite)[kreait/firebase-bundle

Symfony Bundle for the Firebase Admin SDK

1534.7M2](/packages/kreait-firebase-bundle)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[commercetools/commercetools-sdk

The official PHP SDK for the commercetools Composable Commerce APIs

19281.5k](/packages/commercetools-commercetools-sdk)

PHPackages © 2026

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