Plugin Development
A plugin adds features to FinAegis without changing the core code. It listens to hooks, declares its permissions and runs inside a sandbox.
Quick Start
Scaffold a plugin
php artisan plugin:create my-company payment-analytics
The command creates this structure.
plugins/my-company/payment-analytics/ ├── plugin.json ← Manifest (metadata, permissions, deps) ├── src/ │ └── ServiceProvider.php ← Entry point (register + boot) ├── routes/ ├── config/ ├── migrations/ └── tests/
Configure the manifest
{
"vendor": "my-company",
"name": "payment-analytics",
"version": "1.0.0",
"display_name": "Payment Analytics",
"description": "Real-time payment analytics and reporting dashboard",
"author": "My Company",
"license": "Apache-2.0",
"entry_point": "ServiceProvider",
"permissions": [
"database:read",
"events:listen",
"cache:read",
"cache:write"
],
"dependencies": {},
"extra": {
"dashboard_url": "/admin/payment-analytics"
}
}
Register a hook listener
namespace Plugins\MyCompany\PaymentAnalytics; use App\Infrastructure\Plugins\PluginHookInterface; use App\Infrastructure\Plugins\PluginHookManager; use Illuminate\Support\ServiceProvider as BaseServiceProvider; class ServiceProvider extends BaseServiceProvider { public function boot(): void { // Register hook listener for completed payments $this->app->make(PluginHookManager::class) ->register(new PaymentCompletedListener()); } } class PaymentCompletedListener implements PluginHookInterface { public function getHookName(): string { return 'payment.completed'; } public function getPriority(): int { return 10; // Lower = runs first } public function handle(array $payload): void { // $payload contains payment data Log::info('Payment analytics: tracking', $payload); } }
Install and enable
php artisan plugin:install plugins/my-company/payment-analytics php artisan plugin:enable my-company/payment-analytics php artisan plugin:list
Available Hooks
A plugin registers listeners for these hook points. The listeners run one after another. If one listener throws an exception, the platform logs it and still runs the others. Today the platform fires five of these hooks: account.created, payment.completed and payment.failed for deposits, order.placed and order.matched. The other hook points are defined but not fired yet.
Account
account.created
An account was created
account.updated
Account details changed
Payments
payment.initiated
A payment started
payment.completed
A deposit completed
payment.failed
A deposit failed
Wallet
wallet.created
A wallet was created
wallet.transfer
A wallet transfer happened
Compliance
compliance.alert
A compliance alert was raised
compliance.kyc
An identity check changed status
Exchange
order.placed
An exchange order was placed
order.matched
An order was matched
Lending
loan.applied
A loan application was sent
loan.approved
A loan was approved
Cross-Chain
bridge.initiated
A bridge transfer started
bridge.completed
A bridge transfer completed
Decentralised Finance
defi.position.opened
A decentralised finance position was opened
defi.position.closed
A decentralised finance position was closed
Permission Model
Plugins declare required permissions in plugin.json. The sandbox checks them while the plugin runs. Access that the plugin did not declare throws a RuntimeException.
| Category | Permission | Description |
|---|---|---|
| Data Access | database:read |
Read from database tables |
database:write |
Write to database tables | |
| API | api:internal |
Access internal API endpoints |
api:external |
Make outbound HTTP requests | |
| Events | events:listen |
Listen to application events |
events:dispatch |
Dispatch application events | |
| Infrastructure | queue:dispatch |
Queue background jobs |
cache:read |
Read from cache | |
cache:write |
Write to cache | |
filesystem:read |
Read files | |
filesystem:write |
Write files | |
config:read |
Read application configuration |
Security Scanner
The security scanner checks a plugin's code for dangerous patterns. You run it with plugin:verify, from the admin panel or through the API. It sorts what it finds into four levels.
Critical
These are the most serious findings. They include eval(), exec(), shell_exec(), system(), backtick execution and dynamic includes.
High
These findings need a careful review. They include DB::raw(), unserialize(), extract() and direct env() access.
Medium
These findings are warnings. They include remote file_get_contents() and curl_exec() calls. Declare the api:external permission instead.
Low
These findings are for information. They point to unusual code that may need a second look.
php artisan plugin:verify my-company/payment-analytics
Plugin Lifecycle
| Command | Action |
|---|---|
plugin:create {vendor} {name} | Creates the plugin folder and its manifest |
plugin:install {path} | Checks the manifest, resolves dependencies and registers the plugin as inactive |
plugin:enable {vendor/name} | Turns the plugin on, boots its service provider and registers its hooks |
plugin:disable {vendor/name} | Turns the plugin off and removes its hooks |
plugin:remove {vendor/name} | Deletes the plugin. System plugins cannot be removed. |
plugin:list | Lists all plugins and their status |
plugin:verify {vendor/name} | Runs the security scanner on the plugin code |
Manifest Reference
These are all the fields of plugin.json.
| Field | Type | Required | Description |
|---|---|---|---|
vendor | string | Yes | Vendor identifier (alphanumeric, hyphens, underscores) |
name | string | Yes | Plugin name (alphanumeric, hyphens, underscores) |
version | string | Yes | Semantic version (X.Y.Z) |
display_name | string | No | Human-readable name (defaults to name) |
description | string | No | Plugin description |
author | string | No | Author name |
license | string | No | License type (default: Apache-2.0) |
entry_point | string | No | ServiceProvider class name (default: ServiceProvider) |
permissions | string[] | No | Required permissions (see table above) |
dependencies | object | No | Semver constraints: {"vendor/name": "^1.0"} |
extra | object | No | Custom metadata, such as dashboard links and a settings schema |
REST & GraphQL APIs
You can also manage plugins through the REST API or through GraphQL.
REST Endpoints
/api/v2/plugins
/api/v2/plugins/{id}
/api/v2/plugins/{id}/enable
/api/v2/plugins/{id}/disable
/api/v2/plugins/{id}/scan
/api/v2/plugins/discover
/api/v2/plugins/{id}
GraphQL Operations
plugin(id: ID!)
plugins(status: String)
pluginMarketplaceStats
enablePlugin(id: ID!)
disablePlugin(id: ID!)
scanPlugin(id: ID!)