A comprehensive Laravel package for integrating with the n8n API using clean architecture patterns. This package provides a facade-based interface with support for multiple execution strategies, request builders, and event observability.
- Facade - Simple static interface (
N8N::workflows()) - Adapter - Clean abstraction of n8n API communication
- Strategy - Multiple execution strategies (sync, async, queued)
- Builder - Fluent API for constructing complex payloads
- Observer - Event hooks for request lifecycle
- Clean Architecture - SOLID principles and separation of concerns
- Type Safety - Full PHP 8.1+ type hints and strict typing
- Event System - Laravel events for request monitoring
- Comprehensive Testing - Pest framework with full test coverage
composer require mrkindy/n8n-laravelphp artisan vendor:publish --provider="MrKindy\N8NLaravel\N8NServiceProvider" --tag="n8n-config"Add these variables to your .env file:
N8N_BASE_URL=http://localhost:5678
N8N_API_KEY=your-api-key-here
N8N_DEFAULT_STRATEGY=sync
N8N_HTTP_TIMEOUT=30
N8N_HTTP_RETRY_TIMES=3
N8N_HTTP_RETRY_SLEEP=1000
N8N_HTTP_VERIFY_SSL=true
N8N_EVENTS_ENABLED=true
N8N_LOGGING_ENABLED=true
N8N_LOGGING_LEVEL=info
N8N_LOGGING_CHANNEL=default
N8N_QUEUE_CONNECTION=default
N8N_QUEUE_NAME=n8nFor detailed usage instructions, please refer to DOCUMENTATION.md.
The package uses the Pest testing framework. Run tests with:
vendor/bin/pesttests/
├── Pest.php # Pest configuration
├── TestCase.php # Base test case
├── Feature/
│ ├── FacadeTest.php # Facade functionality tests
│ ├── BuilderTest.php # Builder tests
│ ├── ObserverTest.php # Observer tests
│ └── StrategyTest.php # Strategy tests
└── Unit/
├── AdapterTest.php # Adapter unit tests
└── ServiceTest.php # Individual service tests
use MrKindy\N8NLaravel\Facades\N8N;
it('can create a workflow', function () {
Http::fake([
'localhost:5678/api/v1/workflows' => Http::response([
'id' => 'workflow-123',
'name' => 'Test Workflow'
])
]);
$result = N8N::workflows()->create([
'name' => 'Test Workflow',
'nodes' => []
]);
expect($result)->toHaveKey('id', 'workflow-123');
});'http' => [
'timeout' => 30, // Request timeout in seconds
'retry' => [
'times' => 3, // Number of retry attempts
'sleep' => 1000, // Sleep between retries (ms)
],
'verify' => true, // SSL certificate verification
],'queue' => [
'connection' => 'redis', // Queue connection
'queue' => 'n8n-operations', // Queue name
],'logging' => [
'enabled' => true, // Enable request logging
'level' => 'info', // Log level
'channel' => 'n8n', // Log channel
],This package provides full coverage of the n8n Public API v1.1.1:
- ✅ List workflows
- ✅ Get workflow
- ✅ Create workflow
- ✅ Update workflow
- ✅ Delete workflow
- ✅ Activate workflow
- ✅ Deactivate workflow
- ✅ Transfer workflow
- ✅ Get workflow tags
- ✅ Update workflow tags
- ✅ Create credential
- ✅ Delete credential
- ✅ Get credential schema
- ✅ Transfer credential
- ✅ List executions
- ✅ Get execution
- ✅ Delete execution
- ✅ List users
- ✅ Get user
- ✅ Create users
- ✅ Delete user
- ✅ Change user role
- ✅ List tags
- ✅ Get tag
- ✅ Create tag
- ✅ Update tag
- ✅ Delete tag
- ✅ List variables
- ✅ Create variable
- ✅ Update variable
- ✅ Delete variable
- ✅ List projects
- ✅ Create project
- ✅ Delete project
- ✅ Add users to project
- ✅ Generate audit
- ✅ Pull changes
- Fork the repository
- Create a feature branch
- Write tests for your changes
- Ensure all tests pass:
vendor/bin/pest - Follow PSR-12 coding standards
- Submit a pull request
git clone https://github.com/mrkindy/n8n-laravel.git
cd n8n-laravel
composer install
cp .env.example .env
# Configure your n8n instance details in .env
vendor/bin/pest- PHP 8.1+
- Laravel 10.0+ or 11.0+
- n8n instance with API access
This package is open-sourced software licensed under the MIT license.
Please see CHANGELOG for more information on what has changed recently.
Built with ❤️ for the Laravel and n8n communities.