PHP code example of milpa / agent-workspace

1. Go to this page and download the library: Download milpa/agent-workspace 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 / agent-workspace example snippets


 // public/router.php
$path = parse_url($_SERVER['REQUEST_URI'] ?? '/', PHP_URL_PATH) ?? '/';
if ($path !== '/' && is_file(__DIR__ . $path)) {
    return false; // serve a real static file as-is
}

// config/app.php
'desktop' => ['middleware' => [Milpa\AppRuntime\Web\PasskeyGateMiddleware::class]],

// config/app.php
'live' => ['secret' => getenv('MILPA_LIVE_SECRET') ?: ''],

// In your plugin's boot():
$events->subscribe(ShellController::COMPOSE_EVENT, [$this, 'onCompose']);

public function onCompose(string $eventName, array $payload): void
{
    $payload['composition']->addPanel('sessions', 'Sessions', <<<'H'
      <p class="mono"><span data-count>0</span> active</p>
      <script>
        MilpaShell.on('session.count', function (d) {
          MilpaShell.panel('sessions').querySelector('[data-count]').textContent = d.count;
        });
      </script>
    H);
}

if ($events instanceof DeclaredEvents) {
    $events->declare(...AgentWorkspaceEvents::declarations());
}