← Files WorkOSARCHIVED FILE
references/framework-php.md
681 Bytes · Oct 2, 2026 · 00:06 UTC
# Framework: PHP
## Scope
Use this guide for PHP apps (for example Laravel/Symfony) that create widget tokens and integrate widget APIs.
## Guidance
- Use the official WorkOS PHP SDK.
- Keep API key in environment configuration.
- Place token generation in existing controller/service boundaries.
- Reuse current auth/session context to resolve organization/user identifiers.
## Token Pattern
```php
<?php
use WorkOS\Resource\WidgetScope;
WorkOS\WorkOS::setApiKey($_ENV['WORKOS_API_KEY']);
$widgets = new WorkOS\Widgets();
$token_response = $widgets->getToken(
organization_id: $organizationId,
user_id: $userId,
scopes: [WidgetScope::UsersTableManage]
);
```
SHA-256: 5ef70a56b602fb968d4f2782b40c9ffcef91b59fdc6c83cc979dbee5f327b1c0