PHPackages                             codelockpro/sdk - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. codelockpro/sdk

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

codelockpro/sdk
===============

Framework-agnostic, modular server-side SDK for CodeLockPro. Module one: Knowledge base. Pure library — no framework binding, no routing.

v0.1.16(4w ago)00proprietaryPHPPHP &gt;=8.1

Since May 10Pushed 4w agoCompare

[ Source](https://github.com/mbos01/codelockpro-sdk-php)[ Packagist](https://packagist.org/packages/codelockpro/sdk)[ Docs](https://github.com/mbos01/codelockpro/tree/main/sdk/php#readme)[ RSS](/packages/codelockpro-sdk/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependenciesVersions (13)Used By (0)

`codelockpro/sdk`
=================

[](#codelockprosdk)

Pure server-side, modular PHP SDK — the CodeLockPro client framework on the server. Ships with the knowledge base as a built-in module and includes portal/community module factories for forum operations; additional modules plug into the same `CodeLockPro` instance through the same registration surface.

Install
-------

[](#install)

```
composer require codelockpro/sdk
```

> **Source repository.** This package is published to Packagist from a read-only subtree mirror at [`mbos01/codelockpro-sdk-php`](https://github.com/mbos01/codelockpro-sdk-php). The canonical source lives in [`mbos01/codelockpro`](https://github.com/mbos01/codelockpro) under `sdk/php/` — open issues and PRs there.

> **License.** The SDK is proprietary and may only be used in combination with an active CodeLockPro account. See [`LICENSE`](./LICENSE).

Architecture invariants
-----------------------

[](#architecture-invariants)

1. **Modular foundation.** The core has no per-module coupling.
2. **Pure library.** No framework binding (Laravel, Symfony, vanilla PHP — the developer wires the routes).
3. **Zero web-framework dependencies.** Only `ext-curl` and `ext-json`.

Usage
-----

[](#usage)

```
use CodeLockPro\CodeLockPro;

$client = new CodeLockPro(
    baseUrl: 'https://api.codelock.pro',
    applicationId: '01H…',
);

// Data
$articles = $client->kb()->getArticles();
$article  = $client->kb()->getArticle('how-to-reset-password');

// Actions (server-side: emits the bus event)
$client->kb()->trackView($article['id'], $article['slug']);

// Events
$client->on('kb.article.viewed', function (array $payload): void {
    error_log("viewed {$payload['article_id']}");
});
$client->on('kb.search.performed', function (array $payload): void {
    error_log("{$payload['count']} results for {$payload['query']}");
});
```

`$client->kb()` is a convenience accessor for `$client->module('kb')`. The core has no KB-specific code path.

Registering more modules
------------------------

[](#registering-more-modules)

```
use CodeLockPro\CodeLockPro;
use CodeLockPro\Core\ModuleContext;

$client = new CodeLockPro(
    baseUrl: 'https://api.codelock.pro',
    applicationId: '01H…',
    modules: false,  // opt out of the default KB registration
);

$client->register('kb',       [\CodeLockPro\Modules\KnowledgeBase::class, 'create']);
$client->register('checkout', function (ModuleContext $ctx) {
    return new class($ctx) {
        public function __construct(public ModuleContext $ctx) {}
        public function start(string $productId): array {
            $session = $this->ctx->client->request(
                'POST', "/v1/checkout/sessions", ['product_id' => $productId],
            );
            $this->ctx->bus->emit("{$this->ctx->name}.session.created", [
                'product_id' => $productId,
            ]);
            return $session;
        }
    };
});

$checkout = $client->module('checkout');
$session  = $checkout->start('pro-monthly');
```

Module author contract
----------------------

[](#module-author-contract)

A module factory is any `callable(ModuleContext): object`. The context exposes:

- `$ctx->name` — the registered name (`"kb"`, `"checkout"`, …)
- `$ctx->client` — back-reference to `CodeLockPro` (use `request()` for HTTP)
- `$ctx->bus` — shared event bus (`on` / `off` / `emit`)

Modules namespace their events as `name>.` so listeners stay unambiguous when many modules are registered.

Knowledge base — module one
---------------------------

[](#knowledge-base--module-one)

Mapped to the unified, secured KB REST surface (every call requires an OAuth bearer carrying `kb:read` for reads and `kb:write` for writes; view tracking is `kb:read`):

```
GET  /v1/kb/{application_id}/articles
GET  /v1/kb/{application_id}/articles/{id_or_slug}
GET  /v1/kb/{application_id}/categories
GET  /v1/kb/{application_id}/search?q=…
POST /v1/kb/{application_id}/articles/{id}/track-view

```

Each call returns the raw decoded JSON body as an associative array. On a non-2xx response the client throws `CodeLockPro\CodeLockProApiException` carrying the HTTP status and response body.

Portal module (canonical)
-------------------------

[](#portal-module-canonical)

Register the canonical portal module via the same module contract:

```
$client->register('portal', [\CodeLockPro\Modules\Portal::class, 'create']);

$threads = $client->portal()->getThreads(['limit' => 20]);
$post    = $client->portal()->createPost('thread_123', ['body' => 'I hit this too']);
```

Community module (backward-compatible alias)
--------------------------------------------

[](#community-module-backward-compatible-alias)

Register the community module via the same module contract:

```
$client->register('community', [\CodeLockPro\Modules\Community::class, 'create']);

$threads = $client->community()->getThreads(['limit' => 20]);
$post    = $client->community()->createPost('thread_123', ['body' => 'I hit this too']);
```

Mapped to the upstream portal forum API surface:

```
GET  /v1/portal/forum/threads
GET  /v1/portal/forum/threads/{threadId}/posts
POST /v1/portal/forum/threads
POST /v1/portal/forum/threads/{threadId}/posts
POST /v1/portal/forum/threads/{threadId}/flag
POST /v1/portal/forum/posts/{postId}/flag

```

Events emitted on the shared bus are namespaced with the registered module name:

- `community.thread.created`
- `community.post.created`
- `community.thread.flagged`
- `community.post.flagged`

When registered as `portal`, event names are emitted as:

- `portal.thread.created`
- `portal.post.created`
- `portal.thread.flagged`
- `portal.post.flagged`

Migration (community → portal)
------------------------------

[](#migration-community--portal)

Legacy community naming is preserved for backward compatibility. New PHP integrations should use portal naming.

LegacyCanonical`CodeLockPro\Modules\Community``CodeLockPro\Modules\Portal``$client->community()``$client->portal()``$client->register('community', ...)``$client->register('portal', ...)`Deprecation policy and timeline:

- `community` naming remains fully supported in the current `0.x` line.
- `portal` naming is the canonical path for all new integrations.
- Any future removal of `community` naming will happen only in a future major release, with migration notice published in advance.

Integrator migration checklist:

- **PHP SDK:** migrate registrations/accessors from `CodeLockPro\Modules\Community` and `$client->community()` to `CodeLockPro\Modules\Portal` and `$client->portal()`.
- **JS SDK parity:** if your stack also uses JS, mirror the same naming shift with `@codelockpro/sdk/portal` and `client.portal()`.
- **Events:** prefer `portal.thread.created`, `portal.post.created`, `portal.thread.flagged`, `portal.post.flagged`; keep `community.*`listeners only until all integrations are migrated.
- **Routes/endpoints:** use portal naming consistently for forum routes (`/portal/*` in proxy layers; `/v1/portal/forum/*` upstream).

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance94

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 94.1% 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 ~0 days

Total

12

Last Release

29d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/12e81eab5db3352e9d6040c449c804a721371a92c613433e7d492f15e40e8a42?d=identicon)[codelockpro](/maintainers/codelockpro)

---

Top Contributors

[![Copilot](https://avatars.githubusercontent.com/in/1143301?v=4)](https://github.com/Copilot "Copilot (16 commits)")[![mbos01](https://avatars.githubusercontent.com/u/59789504?v=4)](https://github.com/mbos01 "mbos01 (1 commits)")

---

Tags

sdkKnowledge Baselicensingcodelockpro

### Embed Badge

![Health badge](/badges/codelockpro-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/codelockpro-sdk/health.svg)](https://phpackages.com/packages/codelockpro-sdk)
```

###  Alternatives

[aws/aws-crt-php

AWS Common Runtime for PHP

422319.4M9](/packages/aws-aws-crt-php)[zumba/amplitude-php

PHP SDK for Amplitude

4010.1M5](/packages/zumba-amplitude-php)[ennnnny/tbk

简约优雅的淘宝客SDK

29416.4k1](/packages/ennnnny-tbk)

PHPackages © 2026

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