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 client = PHPSandbox.rest(process.env.PHPSANDBOX_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.
What to read next
- Authentication and clients to use API keys and choose a client transport.
- End-to-end automation to change, test, and preview a Laravel project.
- Managing sandboxes to retrieve, fork, stop, restart, or delete sandboxes.