1. Go to this page and download the library: Download kayedspace/laravel-n8n library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kayedspace / laravel-n8n example snippets
use KayedSpace\N8n\Facades\N8nClient;
// trigger webhook
$webhookTrigger =N8nClient::webhooks()->request("path-to-webhook",$payload);
// List all workflows
$workflows = N8nClient::workflows()->list();
// Retrieve execution status with data
$status = N8nClient::executions()->get($execution['id'],
//request a webhook
$webhookTrigger =N8nClient::webhooks()->request("path-to-webhook",$payload);
//request a webhook with custom basic auth credentials
//overwrites values provided on .env` file
$webhookTrigger =N8nClient::withBasicAuth("custom-username","custom-password")->request("path-to-webhook",$payload);
//request a webhook without auth
$webhookTrigger =N8nClient::withoutBasicAuth()->request("path-to-webhook",$payload);
// Get a list of executions filtered by status
$executions = N8nClient::executions()->list(['status' => 'success']);
// Get detailed execution data
$execution = N8nClient::executions()->get(101, true);
// Delete an execution
N8nClient::executions()->delete(101);
// Create a project
$project = N8nClient::projects()->create(['name' => 'DevOps', 'description' => 'CI/CD flows']);
// Add users
N8nClient::projects()->addUsers($project['id'], [
['userId' => 'abc123', 'role' => 'member'],
]);
// Promote user role
N8nClient::projects()->changeUserRole($project['id'], 'abc123', 'admin');
// Delete the project
N8nClient::projects()->delete($project['id']);