tv2regionerne/statamic-private-api
Composer 安装命令:
composer require tv2regionerne/statamic-private-api
包简介
README 文档
README
Statamic Private Api is a Statamic addon that enables a private REST API.
The routes should be protected by Laravel Passport, Sanctum or similar.
Features
Add's private API seperated from the Public API build into statamic.
Uses Laravel's build in auth guards, so you may use Laravel Passport, Laravel Sanctum or something else.
Permissions will foloww the permissions assigned to the user inside of Statamic.
See https://statamic.com/addons/tv2reg/laravel-passport-ui for Laravel Passport integration into Statamic.
Limitations
The Private API uses the Statamic CP controllers.
Collection Entry revisions is not implemented.
How to Install
Run the following command from your project root:
composer require tv2regionerne/statamic-private-api
Make sure you have an 'api' guard in your config/auth.php configured.
Below example is using Laravel Passport for api authentication.
'guards' => [ 'web' => [ 'driver' => 'session', 'provider' => 'users', ], 'api' => [ 'driver' => 'passport', 'provider' => 'users', ], ],
Publish the config file:
php artisan vendor:publish --tag=private-api-config
Then, in /config/private-api.php enable the routes you would like to use, for example:
'resources' => [
'collections' => true,
'navs' => false,
'taxonomies' => false,
'assets' => false,
'globals' => false,
'forms' => false,
'users' => true,
],
How to Use
Update the config or env to enable private API's.
Configure your .env with the following values to enable the private API with a prefix on "api/private".
PRIVATE_API_ENABLED=true PRIVATE_API_ROUTE="api/private"
Addon endpoints in private API
Other addons can register their private API endpoints in the private API.
Consider below example which checks if the Private API addon is installed and then adds the addon's private API endpoints.
The routes will be protected by the same auth guard as the other Private API endpoints.
Authorisation and policies should be handled inside of the addon's controllers.
use Illuminate\Support\Facades\Route; use Tv2regionerne\StatamicPrivateApi\Facades\PrivateApi; if (class_exists(PrivateApi::class)) { PrivateApi::addRoute(function () { Route::prefix('/statamic-events/handlers') ->group(function () { Route::get('/', [Controller::class, 'index']); Route::get('{id}', [Controller::class, 'show']); Route::post('/', [Controller::class, 'store']); Route::patch('{id}', [Controller::class, 'update']); Route::delete('{id}', [Controller::class, 'destroy']); }); }); }
tv2regionerne/statamic-private-api 适用场景与选型建议
tv2regionerne/statamic-private-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.83k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2024 年 01 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 tv2regionerne/statamic-private-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 tv2regionerne/statamic-private-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 4.83k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2024-01-08