blackcube/dboard-bridge
最新稳定版本:1.0.0
Composer 安装命令:
composer require blackcube/dboard-bridge
包简介
Blackcube Dboard bridge for non-Yii3 frameworks
README 文档
README
Bridge for running the Blackcube admin panel (dboard) inside non-Yii3 frameworks. Boots a Yii3 sub-application, handles the request, returns a PSR-7 response.
Where dboard-bridge sits
┌─────────────────────────────────┐
│ your app (Slim / Laravel / …) │
└────────────────┬────────────────┘
↓
┌─────────────────────────────────┐
│ dboard-bridge ← you are here │
│ boots Yii3, returns PSR-7 │
└────────────────┬────────────────┘
↓
┌──────────────┐
│ dboard │
│ (admin panel)│
└──────┬───────┘
↓
┌──────────┐
│ dcore │
│ (data) │
└──────────┘
↓
DB
Quickstart
composer require blackcube/dboard-bridge
Create a dboard/ config directory at your project root with a configuration.php:
<?php declare(strict_types=1); if (!class_exists(\Blackcube\DboardBridge\DboardBridge::class)) { return []; } return [ 'config-plugin' => [ 'di' => 'common/di/*.php', 'di-web' => [ '$di', 'web/di/*.php', ], ], 'config-plugin-options' => [ 'source-directory' => 'dboard', ], ];
The host project must provide DB connection, OAuth2 params and dboard params in this config directory.
Integration
Slim
Native PSR-7 — no conversion needed:
use Blackcube\DboardBridge\DboardBridge; if (class_exists(DboardBridge::class)) { $app->any('/dboard[/{path:.*}]', function () { return DboardBridge::handle( dirname(__DIR__), debug: true, configDirectory: 'dboard', ); }); }
Laravel
Requires manual PSR-7 conversion:
use Blackcube\DboardBridge\DboardBridge; if (class_exists(DboardBridge::class)) { Route::any('/dboard/{path?}', function (Request $request) { $psrFactory = new \HttpSoft\Message\ServerRequestFactory(); $streamFactory = new \HttpSoft\Message\StreamFactory(); $psrRequest = $psrFactory->createServerRequest( $request->method(), $request->fullUrl(), $_SERVER, ); $psrRequest = $psrRequest ->withQueryParams($request->query->all()) ->withCookieParams($_COOKIE) ->withParsedBody($request->all()) ->withBody($streamFactory->createStream($request->getContent())); foreach ($request->headers->all() as $name => $values) { $psrRequest = $psrRequest->withHeader($name, $values); } $psr = DboardBridge::handle( base_path(), debug: true, configDirectory: 'dboard', request: $psrRequest, ); $response = response($psr->getBody()->getContents(), $psr->getStatusCode()); foreach ($psr->getHeaders() as $name => $values) { foreach ($values as $value) { $response->headers->set($name, $value, false); } } return $response; })->where('path', '.*'); }
Laravel also requires CSRF and cookie exemptions in bootstrap/app.php:
$middleware->validateCsrfTokens(except: ['dboard/*', 'dboard']); $middleware->encryptCookies(except: ['PHPSESSID', 'access_token', '_csrf']);
API
DboardBridge::handle(
string $rootPath, // project root
bool $debug = false, // debug mode
string $configDirectory = 'config', // Yii3 config directory
?ServerRequestInterface $request = null, // PSR-7 request (recommended)
): ResponseInterface
The request parameter is recommended when the host framework consumes php://input before Yii3 can read it (Laravel, Symfony). Slim passes PSR-7 natively.
License
BSD-3-Clause. See LICENSE.md.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2026-04-07