PHPackages                             formpanel/formpanel-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. formpanel/formpanel-php

ActiveLibrary[API Development](/categories/api)

formpanel/formpanel-php
=======================

PHP client library for interacting with the FormPanel API

v1.0.0(5mo ago)038↓46.7%1MITPHPPHP ^8.2

Since Nov 25Pushed 2mo agoCompare

[ Source](https://github.com/mihai-adam/formpanel-php)[ Packagist](https://packagist.org/packages/formpanel/formpanel-php)[ RSS](/packages/formpanel-formpanel-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (5)Versions (3)Used By (1)

FormPanel PHP Client
====================

[](#formpanel-php-client)

Official PHP client library for interacting with the FormPanel API. Submit form data programmatically from your PHP applications with full type safety, retry logic, and error handling.

Requirements
------------

[](#requirements)

- PHP 8.2 or higher
- Composer

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require formpanel/formpanel-php
```

Quick Start
-----------

[](#quick-start)

```
use Formpanel\FormClient;

// Initialize the client with your API key and form slug
$client = new FormClient(
    apiKey: 'your-api-key',
    formSlug: 'contact-form',
);

// Submit form data
$result = $client->submit([
    'name' => 'John Doe',
    'email' => 'john@example.com',
    'message' => 'Hello from PHP!',
]);

echo "Submission ID: " . $result->id;
```

Configuration
-------------

[](#configuration)

### Basic Configuration

[](#basic-configuration)

```
use Formpanel\FormClient;

// Default configuration
$client = new FormClient(
    apiKey: 'your-api-key',
    formSlug: 'contact-form',
);

// Custom base URL
$client = new FormClient(
    apiKey: 'your-api-key',
    formSlug: 'contact-form',
    baseUrl: 'https://custom-api.example.com/api/v1',
);

// Custom timeout (default: 30 seconds)
$client = new FormClient(
    apiKey: 'your-api-key',
    formSlug: 'contact-form',
    timeout: 60,
);
```

### Retry Configuration

[](#retry-configuration)

The client includes automatic retry with exponential backoff for transient errors:

```
use Formpanel\FormClient;
use Formpanel\Http\RetryConfig;

// Custom retry configuration
$client = new FormClient(
    apiKey: 'your-api-key',
    formSlug: 'contact-form',
    retryConfig: new RetryConfig(
        maxRetries: 5,           // Maximum retry attempts (default: 3)
        baseDelayMs: 500,        // Base delay in ms (default: 1000)
        maxDelayMs: 60000,       // Maximum delay in ms (default: 30000)
        multiplier: 2.0,         // Exponential multiplier (default: 2.0)
    ),
);

// Disable retries
$client = new FormClient(
    apiKey: 'your-api-key',
    formSlug: 'contact-form',
    retryConfig: RetryConfig::noRetries(),
);
```

### Logging

[](#logging)

Enable PSR-3 compatible logging for debugging:

```
use Formpanel\FormClient;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;

$logger = new Logger('formpanel');
$logger->pushHandler(new StreamHandler('php://stdout', Logger::DEBUG));

$client = new FormClient(
    apiKey: 'your-api-key',
    formSlug: 'contact-form',
    logger: $logger,
);
```

Usage
-----

[](#usage)

### Submit Form Data

[](#submit-form-data)

```
use Formpanel\FormClient;
use Formpanel\Exceptions\ValidationException;
use Formpanel\Exceptions\FormpanelException;

$client = new FormClient(
    apiKey: 'your-api-key',
    formSlug: 'contact-form',
);

try {
    $result = $client->submit([
        'name' => 'Jane Doe',
        'email' => 'jane@example.com',
        'message' => 'I would like more information.',
    ]);

    if ($result->success) {
        echo "Form submitted successfully!\n";
        echo "Submission ID: {$result->id}\n";
        echo "Message: {$result->message}\n";
    }
} catch (ValidationException $e) {
    echo "Validation failed:\n";
    foreach ($e->getErrors() as $field => $errors) {
        echo "  - {$field}: " . implode(', ', $errors) . "\n";
    }
} catch (FormpanelException $e) {
    echo "Error: " . $e->getMessage() . "\n";
}
```

### Get Form Details

[](#get-form-details)

Retrieve form configuration and field definitions:

```
$client = new FormClient(
    apiKey: 'your-api-key',
    formSlug: 'contact-form',
);

$form = $client->get();

echo "Form: {$form->name}\n";
echo "Status: {$form->status}\n";
echo "Fields:\n";

foreach ($form->fields as $field) {
    echo "  - {$field->name} ({$field->type})";
    echo $field->required ? " [required]" : "";
    echo "\n";
}
```

Error Handling
--------------

[](#error-handling)

The library provides specific exception classes for different error scenarios:

### Exception Hierarchy

[](#exception-hierarchy)

```
FormpanelException (base exception)
├── ParseException (response parsing errors)
└── ApiException (API errors with status codes)
    ├── AuthenticationException (401)
    ├── NotFoundException (404)
    ├── ValidationException (422)
    └── RateLimitException (429)

```

### Handling Specific Exceptions

[](#handling-specific-exceptions)

```
use Formpanel\FormClient;
use Formpanel\Exceptions\AuthenticationException;
use Formpanel\Exceptions\ValidationException;
use Formpanel\Exceptions\NotFoundException;
use Formpanel\Exceptions\RateLimitException;
use Formpanel\Exceptions\FormpanelException;

$client = new FormClient(
    apiKey: 'your-api-key',
    formSlug: 'contact-form',
);

try {
    $result = $client->submit($data);

} catch (AuthenticationException $e) {
    // Invalid API key (401)
    echo "Authentication failed: " . $e->getMessage();

} catch (NotFoundException $e) {
    // Form not found (404)
    echo "Form not found: " . $e->getMessage();

} catch (ValidationException $e) {
    // Validation errors (422)
    echo "Validation failed: " . $e->getMessage();

    foreach ($e->getErrors() as $field => $messages) {
        echo "  {$field}: " . implode(', ', $messages) . "\n";
    }

} catch (RateLimitException $e) {
    // Rate limit exceeded (429)
    echo "Rate limit exceeded. Retry after: " . $e->getRetryAfter() . " seconds";

} catch (FormpanelException $e) {
    // Other errors (network issues, parsing errors, etc.)
    echo "Error: " . $e->getMessage();
}
```

Response Objects
----------------

[](#response-objects)

### SubmissionResult

[](#submissionresult)

Returned by `$client->submit()`:

```
$result = $client->submit($data);

$result->id;       // string - Submission UUID
$result->success;  // bool - Whether submission was successful
$result->message;  // string - Success/error message
```

### Form

[](#form)

Returned by `$client->get()`:

```
$form = $client->get();

$form->id;          // string - Form UUID
$form->name;        // string - Form name
$form->slug;        // string - Form slug
$form->description; // ?string - Form description
$form->status;      // string - Form status (e.g., 'active')
$form->fields;      // FormField[] - Array of field definitions
$form->createdAt;   // DateTimeImmutable
$form->updatedAt;   // DateTimeImmutable
```

### FormField

[](#formfield)

```
foreach ($form->fields as $field) {
    $field->name;        // string - Field name/identifier
    $field->label;       // string - Display label
    $field->type;        // string - Field type
    $field->required;    // bool - Whether field is required
    $field->placeholder; // ?string - Placeholder text
    $field->helpText;    // ?string - Help text
    $field->config;      // array - Additional configuration
}
```

Testing
-------

[](#testing)

The client supports dependency injection for testing:

```
use Formpanel\FormClient;
use Formpanel\Http\HttpClientInterface;

// Create a mock HTTP client
$mockHttpClient = new class implements HttpClientInterface {
    public function get(string $uri): array {
        return ['id' => 'test', 'name' => 'Test Form', /* ... */];
    }

    public function post(string $uri, array $data): array {
        return ['submission_id' => 'test-123', 'success' => true, 'message' => 'OK'];
    }
};

// Inject mock client
$client = new FormClient(
    apiKey: 'test-key',
    formSlug: 'test-form',
    httpClient: $mockHttpClient,
);
```

Run the test suite:

```
composer install
composer test
```

Run static analysis:

```
composer analyse
```

Run both:

```
composer check
```

Security
--------

[](#security)

- Always keep your API key secure
- Never commit API keys to version control
- Use environment variables for API keys

```
$client = new FormClient(
    apiKey: getenv('FORMPANEL_API_KEY'),
    formSlug: 'contact-form',
);
```

Support
-------

[](#support)

- GitHub: [github.com/formpanel/formpanel-php](https://github.com/formpanel/formpanel-php)
- Documentation: [formpanel.com/docs](https://formpanel.com/docs)
- Email:

License
-------

[](#license)

MIT License. See [LICENSE](LICENSE) file for details.

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance80

Actively maintained with recent releases

Popularity9

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 83.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

174d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/55f4e276f259b7819e39dde7962b1740ef30b96e7f0ced1905e4cf3aa562c9e1?d=identicon)[mihai.adam](/maintainers/mihai.adam)

---

Top Contributors

[![mihai-adam](https://avatars.githubusercontent.com/u/2922958?v=4)](https://github.com/mihai-adam "mihai-adam (5 commits)")[![claude](https://avatars.githubusercontent.com/u/81847?v=4)](https://github.com/claude "claude (1 commits)")

---

Tags

apiclientFormsformpanel

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/formpanel-formpanel-php/health.svg)

```
[![Health](https://phpackages.com/badges/formpanel-formpanel-php/health.svg)](https://phpackages.com/packages/formpanel-formpanel-php)
```

###  Alternatives

[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k7.6M74](/packages/openai-php-laravel)[algolia/algoliasearch-client-php

API powering the features of Algolia.

69433.0M114](/packages/algolia-algoliasearch-client-php)[theodo-group/llphant

LLPhant is a library to help you build Generative AI applications.

1.5k311.5k5](/packages/theodo-group-llphant)[resend/resend-php

Resend PHP library.

574.7M21](/packages/resend-resend-php)[crowdin/crowdin-api-client

PHP client library for Crowdin API v2

611.5M5](/packages/crowdin-crowdin-api-client)[mozex/anthropic-laravel

Anthropic PHP for Laravel is a supercharged PHP API client that allows you to interact with the Anthropic API

71226.4k1](/packages/mozex-anthropic-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
