定制 ninjaportal/portal 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ninjaportal/portal

Composer 安装命令:

composer require ninjaportal/portal

包简介

A Laravel Like Apigee DevPortal

README 文档

README

Core domain package for NinjaPortal.

It provides:

  • Portal data models (users, categories, API products, audiences, menus, settings)
  • Repository + service abstractions
  • Translatable model support
  • Apigee-backed developer app + credential services
  • Core events/policies/RBAC seeding

ninjaportal/portal intentionally keeps API authentication concerns out of the core package. JWT-aware user/admin models are provided by ninjaportal/portal-api.

Install

From the Laravel app (backend):

php artisan portal:install

Safer install options:

php artisan portal:install --force-provider-overwrite
php artisan portal:install --delete-default-users-migration

Notes:

  • The installer does not overwrite App\Providers\NinjaPortalServiceProvider unless you pass --force-provider-overwrite.
  • The installer does not delete Laravel's default users migration unless you pass --delete-default-users-migration.

Seeding

php artisan portal:seed --all
php artisan portal:seed --settings --rbac
php artisan portal:seed --demo

RBAC And Policies

The package now standardizes model-policy permissions using:

portal.{model}.{ability}

Examples:

  • portal.user.view_any
  • portal.user.update
  • portal.api_product.create
  • portal.setting_group.delete

Route/API level permissions remain:

  • portal.admin.access
  • portal.rbac.manage
  • portal.admins.manage
  • portal.activities.view

The RbacSeeder seeds both route-level permissions and model-policy permissions.

Service Implementation Standards

1. Eloquent-backed domain services

Use this pattern:

  • Extend BaseService
  • Implement a ...ServiceInterface
  • Use CrudOperationsTrait
  • Inject a repository interface in the constructor
  • Keep business-specific methods small and focused

Examples:

  • src/Services/UserService.php
  • src/Services/ApiProductService.php
  • src/Services/SettingService.php

2. External/Apigee-backed services

Use this pattern:

  • Implement a dedicated interface (not ServiceInterface)
  • Wrap LaraApigee service calls
  • Use consistent error logging via ReportsServiceFailuresTrait
  • Emit portal domain events after successful mutations

Examples:

  • src/Services/UserAppService.php
  • src/Services/UserAppCredentialService.php

Event Naming Standard

Preferred event naming is:

{DomainThing}{Action}Event

Examples:

  • UserCreatedEvent
  • ApiProductUpdatedEvent
  • UserAppCredentialCreatedEvent

Publishing policy:

  • ...Event is the canonical and only supported class name
  • do not add no-suffix event classes

FireEventsTrait dispatches the ...Event class only.

Credential-related events may include credentialKey when the operation targets a specific credential (approve/revoke/delete/product mutations). Generated-key events include it when the upstream Apigee client returns the created key.

App-Level Wiring (Listeners / Observers)

The package publishes an app provider stub:

  • App\Providers\NinjaPortalServiceProvider

Use it to wire project-specific listeners/observers (for example syncing users to Apigee on create/update).

Testing And Static Checks (Package)

After installing package dev dependencies:

composer install
composer test
composer analyse
composer format

Known Tradeoffs (Current)

  • Migration rollback safety is not guaranteed for every migration path.
  • Demo seeders are intended for one-time/demo environments and are not guaranteed to be re-runnable.
  • restore() is only supported for models using Eloquent SoftDeletes; other models will throw a clear exception if restore() is called.

ninjaportal/portal 适用场景与选型建议

ninjaportal/portal 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 13 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 02 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「apigee」 「lordjoo」 「laravel-apigee」 「apigee-php」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 ninjaportal/portal 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 ninjaportal/portal 我们能提供哪些服务?
定制开发 / 二次开发

基于 ninjaportal/portal 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 13
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 12
  • 依赖项目数: 5
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-28