plugninja/sdk
Composer 安装命令:
composer require plugninja/sdk
包简介
PHP SDK for plug.ninja — Email, Payments, Auth & Brazilian Data APIs in one API key.
README 文档
README
Official PHP SDK for plug.ninja — Email, Payments, Auth & Brazilian Data APIs with one API key.
Requirements
- PHP 8.1+
- Composer
Installation
composer require plugninja/sdk
Quick Start
<?php use PlugNinja\Plug; $plug = new Plug('your-api-key'); // Send an email $result = $plug->email->send([ 'to' => 'user@example.com', 'subject' => 'Welcome!', 'html' => '<h1>Hello from plug.ninja</h1>', ]); echo $result['messageId'];
// Send email $plug->email->send([ 'to' => 'user@example.com', 'subject' => 'Hello', 'html' => '<h1>Hi</h1>', ]); // Send OTP $plug->email->sendOtp('user@example.com'); // Verify OTP $result = $plug->email->verifyOtp('user@example.com', '123456'); echo $result['token'];
Payments
// Create checkout (Stripe or MercadoPago — configured in dashboard) $checkout = $plug->payment->checkout([ 'amount' => 2990, // in cents 'successUrl' => 'https://yourapp.com/thanks', 'cancelUrl' => 'https://yourapp.com/cancel', 'customerEmail' => 'buyer@example.com', ]); // Redirect user to: echo $checkout['url']; // Create subscription $sub = $plug->payment->subscription([ 'priceId' => 'price_xxx', 'customerEmail' => 'buyer@example.com', 'successUrl' => 'https://yourapp.com/thanks', ]); // Check payment status $status = $plug->payment->status('payment-id'); // Refund $plug->payment->refund('payment-id');
Auth (Social Login)
// Get Google OAuth URL $auth = $plug->auth->google->getAuthUrl([ 'redirectUri' => 'https://yourapp.com/auth/callback', ]); // Redirect user to $auth['url'], then on callback: $result = $plug->auth->google->callback([ 'code' => $_GET['code'], 'redirectUri' => 'https://yourapp.com/auth/callback', ]); echo $result['user']['email']; echo $result['tokens']['accessToken'];
Custom Base URL
For local development or self-hosted instances:
$plug = new Plug('your-api-key', 'http://localhost:4000');
Error Handling
use PlugNinja\PlugException; try { $plug->email->send([ 'to' => 'user@example.com', 'subject' => 'Test', 'html' => '<p>Hello</p>', ]); } catch (PlugException $e) { echo $e->getMessage(); // "From email is required..." echo $e->statusCode; // 400 var_dump($e->body); // Full error response body }
License
MIT
plugninja/sdk 适用场景与选型建议
plugninja/sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「email」 「payments」 「sdk」 「auth」 「saas」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 plugninja/sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 plugninja/sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 plugninja/sdk 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dealing with payments through the Egyptian payment gateway PayMob
Librería para la gestión sencilla de pagos mediante TPV Redsys y Paypal
A PSR-7 compatible library for making CRUD API endpoints
Extensible library for building notifications and sending them via different delivery channels.
Email+ extends Kirby's email capabilities by adding support for multiple email services using the same Kirby email API.
Laravel contact us form package to send email and save to database
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 32
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-14