PHP code example of rawphp / laravel-capabilities

1. Go to this page and download the library: Download rawphp/laravel-capabilities library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rawphp / laravel-capabilities example snippets


// AppServiceProvider::register()
use Rawphp\Capabilities\Persistence\ArrayTableGateway;
use Rawphp\Capabilities\Persistence\TableGateway;

$this->app->singleton(TableGateway::class, function () {
    return new ArrayTableGateway; // or App\Persistence\CustomTableGateway
});

use Rawphp\Capabilities\Facades\Capability;

// 1) Durable file path (recommended for app CI):
Capability::assertSchemaSnapshot(
    'create-invoice',
    base_path('tests/fixtures/capability-schemas/create-invoice.schema.json'),
);

// 2) Conventional directory → `{dir}/{name}.schema.json`:
Capability::assertSchemaSnapshot(
    'create-invoice',
    null,
    base_path('tests/fixtures/capability-schemas'),
);

// 3) In-memory envelope (unit convenience):
Capability::assertSchemaSnapshot('create-invoice', [
    'input_schema' => [/* JSON Schema */],
    'output_schema' => [/* JSON Schema */],
]);

Capability::assertParity('create-invoice', [
    'input' => [
        'customer_id' => 1,
        'amount_cents' => 2500,
        'currency' => 'USD',
    ],
    'surfaces' => ['http', 'registry', 'ai', 'job'],
    // optional shared invoke options:
    // 'actor' => $user, 'tenant_id' => 't-1', 'scope' => $scope,
    'assert' => function ($result): void {
        // runs only when the surface result is success
        expect($result->data['invoice_id'])->toBeInt();
    },
]);
bash
php artisan capabilities:integration-health
bash
php artisan vendor:publish --tag=capabilities-config
php artisan vendor:publish --tag=capabilities-migrations
php artisan migrate