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.
From the Laravel app (backend):
php artisan portal:installSafer install options:
php artisan portal:install --force-provider-overwrite
php artisan portal:install --delete-default-users-migrationNotes:
- The installer does not overwrite
App\Providers\NinjaPortalServiceProviderunless you pass--force-provider-overwrite. - The installer does not delete Laravel's default users migration unless you pass
--delete-default-users-migration.
php artisan portal:seed --all
php artisan portal:seed --settings --rbac
php artisan portal:seed --demoThe package now standardizes model-policy permissions using:
portal.{model}.{ability}
Examples:
portal.user.view_anyportal.user.updateportal.api_product.createportal.setting_group.delete
Route/API level permissions remain:
portal.admin.accessportal.rbac.manageportal.admins.manageportal.activities.view
The RbacSeeder seeds both route-level permissions and model-policy permissions.
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.phpsrc/Services/ApiProductService.phpsrc/Services/SettingService.php
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.phpsrc/Services/UserAppCredentialService.php
Preferred event naming is:
{DomainThing}{Action}Event
Examples:
UserCreatedEventApiProductUpdatedEventUserAppCredentialCreatedEvent
Publishing policy:
...Eventis 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.
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).
After installing package dev dependencies:
composer install
composer test
composer analyse
composer format- 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 EloquentSoftDeletes; other models will throw a clear exception ifrestore()is called.