Skip to content

PHP n8n Client

php-n8n/client: typed PHP client for n8n webhooks

Documentation for php-n8n/client, the PSR-based PHP n8n client for webhooks and execution tracking.

PHP n8n Client

What Is php-n8n/client?

php-n8n/client is a lightweight PHP library for applications that need to trigger n8n workflows through webhooks and optionally track executions through the n8n API.

It is the package behind searches such as php-n8n, php n8n, php-n8n client, php n8n client, php-n8n-client, and n8n PHP client.

It is designed around standards rather than framework integrations. The runtime dependencies are PSR interfaces:

DependencyPurpose
psr/http-clientSends PSR-7 requests through a PSR-18 client.
psr/http-factoryCreates PSR-7 requests and streams.
psr/http-messageRepresents requests, responses, streams, and URIs.

You install concrete implementations yourself, for example Guzzle for PSR-18 and Nyholm PSR-7 for PSR-17/PSR-7.

bash
composer require php-n8n/client guzzlehttp/guzzle nyholm/psr7

Minimal Example

php
<?php

declare(strict_types=1);

use GuzzleHttp\Client as GuzzleClient;
use Nyholm\Psr7\Factory\Psr17Factory;
use PhpN8n\Client\N8nClient;
use PhpN8n\Client\Webhooks\Webhook;
use PhpN8n\Client\Webhooks\WebhookRequest;

$psr17 = new Psr17Factory();

$client = new N8nClient(
    httpClient: new GuzzleClient(),
    requestFactory: $psr17,
    streamFactory: $psr17,
);

$response = $client->webhooks()->trigger(
    Webhook::fromUri($psr17->createUri('https://n8n.example.com/webhook/order-created')),
    WebhookRequest::json([
        'orderId' => 'ORD-1001',
        'total' => 129.50,
    ]),
);

$body = $response->body();

Next Steps

  • Start with Getting Started for installation and the first webhook call.
  • Read Webhooks for request bodies, headers, query parameters, and responses.
  • Read Execution Tracking if you need to poll n8n workflow executions.
  • Read Laravel Usage for a practical service-provider setup.

Released under the MIT License.