PHP code example of milpa / framework

1. Go to this page and download the library: Download milpa/framework 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/ */

    

milpa / framework example snippets


new Operation(
    name: 'backup_create',
    description: 'Take a backup of the data directory',
    handler: [BackupHandler::class, 'create'],
    inputSchema: ['type' => 'object', 'properties' => [
        'label' => ['type' => 'string', 'description' => 'How to name it'],
    ]],
    mutating: true,
    

return ['expose' => ['plugins.list']];   //  →  GET /plugins

// config/http.php
return ['expose' => ['plugins.list']];

$dispatcher->subscribe('operation.executing', function (array $payload): void {
    $op = $payload['event']->operation;
    if ($op->mutating && $payload['event']->surface === 'http') {
        $payload['slot']->stop();                       // deny it
        // $payload['slot']->shortCircuit($cached);     // …or answer for it
    }
});

$dispatcher->subscribe('operation.executed', function (array $payload): void {
    $e = $payload['event'];   // ->result, ->surface, ->ran(), ->shortCircuited, ->stopped, ->error
});
bash
export MILPA_AGENT_BASE_URL=https://llama.local
export MILPA_AGENT_BASIC_AUTH=user:pass      # if the endpoint asks for it
export MILPA_AGENT_MODEL=qwen3-coder:30b
php bin/coa agent "which plugins are on?"