Orchesty PHP SDK
The Orchesty PHP SDK provides a robust Symfony-based framework for developing custom integrations, applications, and connectors within the Orchesty platform. It leverages Symfony's dependency injection, event system, and service container to simplify interaction with the orchestration layer and external services.
Purpose #
- Framework for Integrations: Offers a structured way to build connectors and applications using Symfony components.
- Communication Layer: Facilitates seamless data exchange between your service and the Orchesty orchestration layer.
- Extensibility: Design custom nodes, applications, and connectors that can be reused across various workflows.
- Symfony Integration: Built on top of Symfony framework with full DI container support and modern PHP practices.
Getting Started #
To begin developing with the PHP SDK, ensure you have a basic understanding of Orchesty's architecture and integration concepts.
If you're using the Orchesty-skeleton, the SDK is already set up. For standalone projects, install it via Composer:
composer require orchesty/php-sdk
Key Features #
- Type-Safe Development: Built with strict typing and modern PHP 8+ features for better code quality.
- HTTP Client Integration: Simplified API calls with
CurlManagerandRequestDto. - Form Generation: Define user-friendly configuration forms with
FormStackandFieldcomponents. - OAuth2 & OAuth1 Support: Streamlined implementation of OAuth authorization flows.
- Process Data Handling: Robust
ProcessDtofor managing data flow and control. - Symfony DI Container: Full integration with Symfony's service container for dependency injection.
- MongoDB Persistence: Built-in support for MongoDB document storage with
ApplicationInstall.
SDK Components #
Explore the core components of the PHP SDK:
Core Classes #
- CommonNodeAbstract: Base class for custom nodes providing fundamental utilities.
- BatchAbstract: Base class for nodes designed for batch processing.
- SymfonyDIContainer: Guide for registering components in Symfony's DI container.
Application & Authorization #
- BasicApplicationAbstract: Base for applications using basic authentication (API keys, username/password).
- OAuth2ApplicationAbstract: Base for applications implementing OAuth2 authorization.
- OAuth1ApplicationAbstract: Base for applications implementing OAuth 1.0a authorization.
- ConnectorAbstract: Base class for creating reusable connectors to interact with external APIs.
- ApplicationInstall: Represents an installed application instance with user-specific settings.
Forms & Fields #
- Form: Defines a single configuration form within an application.
- FormStack: Manages a collection of forms for complex application configurations.
- Field: Represents an individual input field within a form.
Data Transfer Objects (DTOs) #
- ProcessDto: The primary data object flowing through integration processes.
- BatchProcessDto: Specialized DTO for batch processing operations.
PHP-Specific Patterns #
Symfony Service Registration #
All connectors, applications, and nodes must be registered in Symfony's service container:
# config/services.yaml
services:
_instanceof:
Hanaboso\PipesPhpSdk\Connector\ConnectorAbstract:
tags: ['hbpf.connector']
Hanaboso\PipesPhpSdk\Application\Base\ApplicationInterface:
tags: ['hbpf.application']
YourApp\Connector\:
resource: '../src/Connector'
autowire: true
YourApp\Application\:
resource: '../src/Application'
autowire: true
Dependency Injection #
The SDK fully leverages Symfony's DI container:
<?php declare(strict_types=1);
namespace YourApp\Connector;
use Hanaboso\PipesPhpSdk\Application\Repository\ApplicationInstallRepository;
use Hanaboso\PipesPhpSdk\Connector\ConnectorAbstract;
final class MyConnector extends ConnectorAbstract
{
// Dependencies are automatically injected via constructor
public function __construct(
ApplicationInstallRepository $repository
) {
parent::__construct($repository);
}
}
Traits for Functionality #
The SDK uses traits to provide shared functionality:
// ConnectorTrait - HTTP client management
$response = $this->getSender()->send($request);
$this->evaluateStatusCode($response->getStatusCode(), $dto);
// CommonNodeTrait - Application access
$applicationInstall = $this->getApplicationInstallFromProcess($dto);
$settings = $applicationInstall->getSettings();
Comparison with Node.js SDK #
| Feature | PHP SDK | Node.js SDK |
|---|---|---|
| Naming | BasicApplicationAbstract | ABasicApplication |
| DI | Symfony Container | DIContainer class |
| Types | PHP 8+ types, strict mode | TypeScript interfaces |
| Async | Synchronous | Async/await support |
| Persistence | MongoDB via DocumentAbstract | MongoDB via managers |
| HTTP | CurlManager | CurlSender |
Next Steps #
- Learn how to create your first connector.
- Understand how to build applications with basic authentication.
- Dive into OAuth2 application development.
- Register your components in the Symfony DI Container.