trstd/cot-integration-library
Composer 安装命令:
composer require trstd/cot-integration-library
包简介
A PHP integration library for connecting to Community of Trust platform.
README 文档
README
This library provides a comprehensive PHP interface for integrating with the Community of Trust (COT) platform, facilitating seamless interactions with its services.
Requirements
- PHP >= 7.4
- Composer for managing dependencies
Installation
To install the library, run the following command in your project directory:
composer require trstd/cot-integration-library
Usage
Here is a basic example of how to use the library:
On the backend side:
<?php require_once 'vendor/autoload.php'; use TRSTD\COT\Client; // Initialize the client $client = new Client( <CLIENT_ID>, // Client ID - e.g. 'cot-switch-X1234567890123456789012345678901' <CLIENT_SECRET>, // Client Secret - e.g. '1234567890123456789012345678901234567890123456789012345678901234' <AUTH_STORAGE_INSTANCE>, // It can be any storage option implementing AuthStorageInterface - e.g. new DatabaseAuthStorage() <ENV> // Environment (optional) - dev, qa, or prod, defaults to prod ); // Invoke handleCallback function to handle code coming from the authentication server $client->handleCallback(); // Get consumer data for the current user $consumerData = $client->getConsumerData(); // Access consumer information if ($consumerData) { $firstName = $consumerData->getFirstName(); $membershipStatus = $consumerData->getMembershipStatus(); $membershipSince = $consumerData->getMembershipSince(); }
On the frontend side, place the following code in your HTML file where you want the widget to appear:
<trstd-login tsId="X1234567890123456789012345678901"></trstd-login> <script type="module" src="https://cdn.trstd-login.trstd.com/trstd-login/script.js"></script>
For more detailed examples, please refer to the examples/ directory.
Development
Prerequisites
- PHP >= 7.4
- Composer
- Docker (optional, for containerized development)
Setup
-
Install dependencies:
composer install
-
Generate certificates (for HTTPS testing):
make certs
-
Start development environment:
make dev
Configuration
-
Create configuration file:
cp test-environment/config.example.php test-environment/config.php
-
Update configuration with your credentials:
<?php return [ 'tlciid' => 'YOUR_ACTUAL_TLCIID', 'client_id' => 'YOUR_ACTUAL_CLIENT_ID', 'client_secret' => 'YOUR_ACTUAL_CLIENT_SECRET', 'environment' => 'qa' ]; ?>
Development Commands
The project includes a comprehensive Makefile with the following commands:
🐳 Docker Environment
make dev- Start Docker with live file watchingmake docker-stop- Stop Docker environment
🔐 Certificates
make certs- Generate self-signed localhost TLS certs for HTTPS (8443)
Testing
The project includes a test environment for development and testing:
-
Start the test environment:
make dev
-
Access the test page:
- HTTPS (recommended): https://localhost:8443/oauth-integration-test.php
- HTTP (dev only): http://localhost:8081/oauth-integration-test.php
-
Run automated tests:
make test
Debugging
For debugging with Xdebug:
-
Start Xdebug in your IDE first (Cursor, VS Code, PhpStorm)
-
Run development environment:
make dev
-
Set breakpoints in your PHP code
-
Visit test page: https://localhost:8443/oauth-integration-test.php
-
Code will pause at breakpoints for inspection
Important: Always start Xdebug in IDE before running make dev. The environment will attach to your IDE's debugger on host.docker.internal:9003.
Contributing
Contributions are welcome! Please refer to the CONTRIBUTING.md file for guidelines.
License
This library is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- firebase/php-jwt for JWT handling
- phpseclib/phpseclib for security features
- monolog/monolog for logging
- symfony/http-client for HTTP client features
Versioning
This project adheres to Semantic Versioning. For the versions available, see the tags on this repository.
PHP Package Repository
This library is available on Packagist.
trstd/cot-integration-library 适用场景与选型建议
trstd/cot-integration-library 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 116 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 07 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「library」 「integration」 「trustedshops」 「cot」 「trstd」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 trstd/cot-integration-library 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 trstd/cot-integration-library 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 trstd/cot-integration-library 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
LinkedIn API PHP SDK with OAuth 2.0 & CSRF support. Can be used for social sign in or sharing on LinkedIn. Examples. Documentation.
LinkedIn API PHP SDK with OAuth 2.0 & CSRF support. Can be used for social sign in or sharing on LinkedIn. Examples. Documentation.
Inbox pattern process implementation for your Laravel Applications
Laravel integration for blade-to-react
Core library that defines common interfaces used by the rest of the intahwebz..
Amqp classes
统计信息
- 总下载量: 116
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 18
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-07-08