Documentation
Start here/SDK quickstart•1 min read

SDK quickstart

Create and control your first sandbox from an application or integration.

Browse Docs

SDK quickstart

Use the TypeScript/JavaScript SDK to create a Laravel sandbox and run an Artisan command inside it.

Requirements

  • Node.js 18 or newer
  • A PHPSandbox account with an active Platform subscription and SDK access
  • A PHPSandbox API key

Install the SDK:

npm install @phpsandbox/sdk

Open API keys in PHPSandbox, create a key, and add it to your environment:

export PHPSANDBOX_TOKEN="your-api-key"

Keep the key in trusted server-side code and do not commit it to source control.

Create a Laravel sandbox

Save the following as quickstart.mjs:

import { PHPSandbox } from '@phpsandbox/sdk';

const token = process.env.PHPSANDBOX_TOKEN;
if (!token) throw new Error('PHPSANDBOX_TOKEN is required');

const client = PHPSandbox.rest(token);
const sandbox = await client.notebook.create('laravel');
const result = await sandbox.exec('php artisan about');

console.log(result.stdout);

Run it:

node quickstart.mjs

The SDK creates a Laravel sandbox, waits until it can run the command, and prints information about the Laravel project. The sandbox remains available in PHPSandbox, where you can open it in the Workspace and continue working.