tigusigalpa/manus-ai-php

πŸš€ Manus AI PHP SDK - Complete library for integration with Manus AI API. Easy integration of Manus AI agent into PHP applications with Laravel support. Task automation, AI agents, file management. Full documentation, code examples, API support.

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 8

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/tigusigalpa/manus-ai-php

v1.1.0 2025-12-19 01:31 UTC

This package is auto-updated.

Last update: 2026-01-29 16:59:11 UTC


README

Manus AI PHP SDK

πŸš€ The Ultimate PHP Library for Manus AI Integration πŸš€

Unlock the power of AI automation in your PHP applications with enterprise-grade reliability

License: MIT PHP Version Laravel Packagist Downloads

🌟 Why Choose Manus AI PHP SDK?

Welcome to the most comprehensive and developer-friendly PHP SDK for Manus AI - the cutting-edge AI agent platform that's revolutionizing workflow automation. Whether you're building intelligent chatbots, automating complex business processes, or creating AI-powered applications, this SDK provides everything you need to harness the full potential of Manus AI's advanced capabilities.

🎯 Perfect For:

  • 🏒 Enterprise Applications: Build scalable AI-powered solutions with robust error handling and type safety
  • πŸ€– Chatbot Development: Create intelligent conversational interfaces with context-aware responses
  • πŸ“Š Data Analysis: Automate document processing, report generation, and data extraction workflows
  • πŸ”„ Workflow Automation: Streamline repetitive tasks with AI-driven automation
  • πŸ’Ό SaaS Platforms: Integrate AI capabilities into your software-as-a-service products
  • πŸŽ“ Educational Tools: Develop AI-assisted learning and tutoring applications
  • πŸ“± Mobile Backends: Power your mobile apps with intelligent server-side AI processing

πŸ’Ž What Makes This SDK Special?

This isn't just another API wrapper - it's a production-ready, battle-tested solution designed by developers, for developers. Built with modern PHP 8.2+ features, comprehensive Laravel integration, and an intuitive API that feels natural to use. Every method is documented, every edge case is handled, and every feature is tested.

πŸ“‹ Table of Contents

✨ Powerful Features That Set You Apart

🎨 Core Capabilities

  • βœ… Complete Manus AI API Coverage: Full implementation of all Manus AI endpoints with zero compromises
  • βœ… Intelligent Task Management: Create, monitor, update, and control AI agent tasks with granular control
  • βœ… Advanced File Handling: Seamless file upload, attachment management, and multi-format support (PDF, images, documents)
  • βœ… Real-Time Webhook Integration: Stay synchronized with instant notifications for task lifecycle events
  • βœ… Multi-Model Support: Access to Manus 1.6, Lite, and Max variants for optimal performance/cost balance

πŸš€ Laravel Excellence

  • βœ… Native Laravel Integration: First-class service provider, facade, and dependency injection support
  • βœ… Powerful Artisan Commands: Manage AI tasks directly from your terminal with intuitive CLI tools
  • βœ… Configuration Publishing: Customize every aspect through Laravel's familiar config system
  • βœ… Environment-Based Setup: Secure API key management through .env files

πŸ›‘οΈ Enterprise-Grade Quality

  • βœ… Comprehensive Error Handling: Graceful failure management with detailed exception messages
  • βœ… Type-Safe Architecture: Full PHP 8.2+ type hints for IDE autocomplete and early error detection
  • βœ… 100% Test Coverage: Extensive PHPUnit test suite ensuring reliability
  • βœ… PSR-4 Autoloading: Modern PHP standards compliance for seamless integration
  • βœ… Production-Ready: Battle-tested in real-world applications

πŸ“š Developer Experience

  • βœ… Extensive Documentation: Every method documented with examples and use cases
  • βœ… Working Code Examples: Ready-to-run examples for common scenarios
  • βœ… Helper Classes: Convenient utilities for attachments, profiles, and webhook handling
  • βœ… Intuitive API Design: Methods that feel natural and follow PHP conventions
  • βœ… Active Maintenance: Regular updates and community support

πŸ“¦ Requirements

  • PHP 8.2 or higher
  • Composer
  • Guzzle HTTP client (^7.8)
  • Laravel 8+ (optional, for Laravel integration)

πŸ”§ Installation & Quick Start

Step 1: Install via Composer

Getting started is as simple as running a single command. The SDK is available on Packagist and can be installed in seconds:

composer require tigusigalpa/manus-ai-php

This will automatically install all required dependencies, including the Guzzle HTTP client for reliable API communication.

Step 2: Get Your API Key

Before you can start creating AI-powered tasks, you'll need an API key from Manus AI:

  1. 🌐 Visit Manus AI and create a free account
  2. πŸ”‘ Navigate to API Integration Settings
  3. πŸ“‹ Copy your unique API key

Step 3: Quick Start (30 Seconds)

Create your first AI task in just a few lines of code:

<?php
require 'vendor/autoload.php';

use Tigusigalpa\ManusAI\ManusAIClient;

// Initialize the client
$client = new ManusAIClient('your-api-key-here');

// Create your first AI task
$result = $client->createTask('Write a creative story about a PHP developer who discovers AI');

// Get the results
echo "βœ… Task Created Successfully!\n";
echo "πŸ“‹ Task ID: {$result['task_id']}\n";
echo "πŸ”— View Task: {$result['task_url']}\n";

That's it! You're now ready to build powerful AI-driven applications. πŸŽ‰

For Laravel Users

Laravel developers get even more convenience with automatic service provider registration:

# Install the package
composer require tigusigalpa/manus-ai-php

# Add your API key to .env
echo "MANUS_AI_API_KEY=your-api-key-here" >> .env

# Test the connection
php artisan manus-ai:test

βš™οΈ Configuration

Getting Your API Key

  1. Sign up at Manus AI
  2. Get your API key from the API Integration settings

PHP Configuration

use Tigusigalpa\ManusAI\ManusAIClient;

$apiKey = 'your-api-key-here';
$client = new ManusAIClient($apiKey);

Laravel Configuration

1. Publish Configuration (Optional)

php artisan vendor:publish --tag=manus-ai-config

2. Add to .env

MANUS_AI_API_KEY=your-api-key-here
MANUS_AI_DEFAULT_AGENT_PROFILE=manus-1.6
MANUS_AI_DEFAULT_TASK_MODE=agent

πŸš€ Usage

This SDK provides a simple and intuitive interface to interact with Manus AI's powerful automation capabilities. Whether you're creating AI-powered tasks, managing file attachments, or setting up real-time notifications, the SDK handles all the complexity of API communication for you.

Basic Usage

use Tigusigalpa\ManusAI\ManusAIClient;

$client = new ManusAIClient('your-api-key');

// Create a task
$result = $client->createTask('Write a poem about PHP programming', [
    'agentProfile' => 'manus-1.6',
    'taskMode' => 'chat',
]);

echo "Task created: {$result['task_id']}\n";
echo "View at: {$result['task_url']}\n";

Task Management

Tasks are the core of Manus AI - they represent AI agent work items that can perform complex operations, answer questions, or automate workflows. Each task has a lifecycle from creation through execution to completion, and you can monitor and control every step of the process.

API Documentation: Tasks API Reference

Create a Task

API Docs: Create Task

use Tigusigalpa\ManusAI\Helpers\AgentProfile;

$task = $client->createTask('Your task prompt here', [
    'agentProfile' => AgentProfile::MANUS_1_6,  // or AgentProfile::MANUS_1_6_LITE, MANUS_1_6_MAX
    'taskMode' => 'agent',                       // 'chat', 'adaptive', or 'agent'
    'locale' => 'en-US',
    'hideInTaskList' => false,
    'createShareableLink' => true,
]);

Available Agent Profiles:

  • AgentProfile::MANUS_1_6 - Latest and most capable model (recommended)
  • AgentProfile::MANUS_1_6_LITE - Faster, lightweight version
  • AgentProfile::MANUS_1_6_MAX - Maximum capability version
  • AgentProfile::SPEED - ⚠️ Deprecated, use MANUS_1_6_LITE instead
  • AgentProfile::QUALITY - ⚠️ Deprecated, use MANUS_1_6 instead
// Or use string values directly
$task = $client->createTask('Your prompt', [
    'agentProfile' => 'manus-1.6',
]);

Get Task Details

API Docs: Get Task

$task = $client->getTask('task_id');

echo "Status: {$task['status']}\n";
echo "Credits used: {$task['credit_usage']}\n";

// Access output messages
foreach ($task['output'] as $message) {
    echo "[{$message['role']}]: {$message['content']}\n";
}

List Tasks

API Docs: Get Tasks

$tasks = $client->getTasks([
    'limit' => 10,
    'order' => 'desc',
    'orderBy' => 'created_at',
    'status' => ['completed', 'running'],
]);

foreach ($tasks['data'] as $task) {
    echo "Task {$task['id']}: {$task['status']}\n";
}

Update Task

API Docs: Update Task

$updated = $client->updateTask('task_id', [
    'title' => 'New Task Title',
    'enableShared' => true,
    'enableVisibleInTaskList' => true,
]);

Delete Task

API Docs: Delete Task

$result = $client->deleteTask('task_id');
echo "Deleted: " . ($result['deleted'] ? 'yes' : 'no') . "\n";

File Management

Manus AI supports file attachments to provide context for your tasks. The file upload process uses a two-step approach: first, create a file record to get a secure presigned URL, then upload your content directly to cloud storage. Once uploaded, files can be attached to tasks for analysis, processing, or reference.

API Documentation: Files API Reference

Upload a File

API Docs: Create File

use Tigusigalpa\ManusAI\Helpers\TaskAttachment;

// 1. Create file record
$fileResult = $client->createFile('document.pdf');

// 2. Upload file content
$fileContent = file_get_contents('/path/to/document.pdf');
$client->uploadFileContent(
    $fileResult['upload_url'],
    $fileContent,
    'application/pdf'
);

// 3. Use file in task
$attachment = TaskAttachment::fromFileId($fileResult['id']);

$task = $client->createTask('Analyze this document', [
    'attachments' => [$attachment],
]);

Different Attachment Types

use Tigusigalpa\ManusAI\Helpers\TaskAttachment;

// From file ID
$attachment1 = TaskAttachment::fromFileId('file_123');

// From URL
$attachment2 = TaskAttachment::fromUrl('https://example.com/image.jpg');

// From base64
$attachment3 = TaskAttachment::fromBase64($base64Data, 'image/png');

// From local file path
$attachment4 = TaskAttachment::fromFilePath('/path/to/file.pdf');

List Files

API Docs: List Files

$files = $client->listFiles();

foreach ($files['data'] as $file) {
    echo "{$file['filename']} - {$file['status']}\n";
}

Delete File

API Docs: Delete File

$result = $client->deleteFile('file_id');

Webhooks

Webhooks enable real-time notifications about your task lifecycle events. Instead of polling for updates, Manus AI will send HTTP POST requests to your specified endpoint whenever important events occur - such as task creation or completion. This allows you to build reactive workflows, update dashboards instantly, or trigger automated actions based on task results.

Manus AI supports two key event types:

  • task_created: Fired immediately when a task is created via the API
  • task_stopped: Fired when a task completes successfully or requires user input

API Documentation: Webhooks Guide

Create Webhook

API Docs: Create Webhook

$webhook = $client->createWebhook([
    'url' => 'https://your-domain.com/webhook/manus-ai',
    'events' => ['task_created', 'task_stopped'],
]);

echo "Webhook ID: {$webhook['webhook_id']}\n";

Handle Webhook Events

use Tigusigalpa\ManusAI\Helpers\WebhookHandler;

// In your webhook endpoint
$payload = WebhookHandler::parsePayload($request->getContent());

if (WebhookHandler::isTaskCompleted($payload)) {
    $taskDetail = WebhookHandler::getTaskDetail($payload);
    $attachments = WebhookHandler::getAttachments($payload);
    
    echo "Task completed: {$taskDetail['task_id']}\n";
    echo "Message: {$taskDetail['message']}\n";
    
    // Download attachments
    foreach ($attachments as $attachment) {
        echo "File: {$attachment['file_name']} ({$attachment['size_bytes']} bytes)\n";
        echo "URL: {$attachment['url']}\n";
    }
}

if (WebhookHandler::isTaskAskingForInput($payload)) {
    // Task needs user input
    $taskDetail = WebhookHandler::getTaskDetail($payload);
    echo "Input required: {$taskDetail['message']}\n";
}

Delete Webhook

API Docs: Delete Webhook

$client->deleteWebhook('webhook_id');

Laravel Integration

The SDK includes first-class Laravel support with a service provider, facade, and Artisan commands. Once configured, you can use Manus AI seamlessly within your Laravel application through dependency injection or the convenient facade.

Using Facade

use Tigusigalpa\ManusAI\Laravel\ManusAI;

// Create task
$result = ManusAI::createTask('Your prompt here');

// Get task
$task = ManusAI::getTask('task_id');

// List tasks
$tasks = ManusAI::getTasks(['limit' => 10]);

Using Dependency Injection

use Tigusigalpa\ManusAI\ManusAIClient;

class TaskController extends Controller
{
    public function create(ManusAIClient $manus)
    {
        $result = $manus->createTask('Generate report');
        
        return response()->json([
            'task_id' => $result['task_id'],
            'url' => $result['task_url'],
        ]);
    }
}

Artisan Commands

Test connection:

php artisan manus-ai:test
php artisan manus-ai:test --task="Custom test prompt"

Manage tasks:

# Create task
php artisan manus-ai:task create --prompt="Your prompt" --profile=manus-1.6

# List tasks
php artisan manus-ai:task list --limit=10 --status=completed

# Get task details
php artisan manus-ai:task get --id=task_123

# Update task
php artisan manus-ai:task update --id=task_123 --title="New Title"

# Delete task
php artisan manus-ai:task delete --id=task_123

πŸ“š API Reference

ManusAIClient Methods

Task Methods

  • createTask(string $prompt, array $options = []): array
  • getTasks(array $filters = []): array
  • getTask(string $taskId): array
  • updateTask(string $taskId, array $updates): array
  • deleteTask(string $taskId): array

File Methods

  • createFile(string $filename): array
  • uploadFileContent(string $uploadUrl, string $fileContent, string $contentType): bool
  • listFiles(): array
  • getFile(string $fileId): array
  • deleteFile(string $fileId): array

Webhook Methods

  • createWebhook(array $webhook): array
  • deleteWebhook(string $webhookId): bool

Helper Classes

TaskAttachment

  • TaskAttachment::fromFileId(string $fileId): array
  • TaskAttachment::fromUrl(string $url): array
  • TaskAttachment::fromBase64(string $data, string $mimeType): array
  • TaskAttachment::fromFilePath(string $path): array

AgentProfile

  • AgentProfile::MANUS_1_6 - Latest model (recommended)
  • AgentProfile::MANUS_1_6_LITE - Lightweight version
  • AgentProfile::MANUS_1_6_MAX - Maximum capability version
  • AgentProfile::SPEED - Deprecated
  • AgentProfile::QUALITY - Deprecated
  • AgentProfile::all(): array - Get all profiles
  • AgentProfile::recommended(): array - Get recommended profiles
  • AgentProfile::isValid(string $profile): bool
  • AgentProfile::isDeprecated(string $profile): bool

WebhookHandler

  • WebhookHandler::parsePayload(string $json): array
  • WebhookHandler::isTaskCreated(array $payload): bool
  • WebhookHandler::isTaskStopped(array $payload): bool
  • WebhookHandler::isTaskCompleted(array $payload): bool
  • WebhookHandler::isTaskAskingForInput(array $payload): bool
  • WebhookHandler::getTaskDetail(array $payload): ?array
  • WebhookHandler::getAttachments(array $payload): array

🎯 Real-World Use Cases & Success Stories

Discover how developers and businesses are leveraging Manus AI PHP SDK to transform their applications:

πŸ“ Content Generation & Marketing

Automated Blog Post Creation

$task = $client->createTask(
    'Write a comprehensive 1500-word blog post about the benefits of AI in e-commerce, 
    including SEO keywords, meta description, and engaging headlines',
    ['agentProfile' => AgentProfile::MANUS_1_6]
);

Social Media Management

$task = $client->createTask(
    'Create 10 engaging social media posts for a tech startup launching a new SaaS product. 
    Include hashtags and call-to-action for each platform: Twitter, LinkedIn, and Instagram'
);

πŸ“Š Business Intelligence & Data Analysis

Automated Report Generation

// Upload sales data
$fileResult = $client->createFile('sales_data_q4.xlsx');
$client->uploadFileContent($fileResult['upload_url'], $fileContent, 'application/vnd.ms-excel');

// Analyze and generate report
$task = $client->createTask(
    'Analyze this sales data and create a comprehensive quarterly report with insights, 
    trends, and recommendations for Q1 strategy',
    ['attachments' => [TaskAttachment::fromFileId($fileResult['id'])]]
);

Customer Feedback Analysis

$task = $client->createTask(
    'Analyze 500+ customer reviews and provide: sentiment analysis, common pain points, 
    feature requests, and actionable recommendations for product improvement'
);

πŸ€– Customer Support Automation

Intelligent Ticket Response

// In your support ticket system
$ticketContent = $ticket->getDescription();
$task = ManusAI::createTask(
    "Generate a professional, empathetic response to this customer support ticket: {$ticketContent}. 
    Include troubleshooting steps and escalation options if needed."
);

FAQ Generation

$task = $client->createTask(
    'Based on our product documentation, create a comprehensive FAQ section with 20 
    common questions and detailed answers for our help center'
);

οΏ½ E-commerce & Product Management

Product Description Writer

$task = $client->createTask(
    'Write compelling, SEO-optimized product descriptions for: ' . json_encode($products) . 
    '. Include features, benefits, specifications, and persuasive call-to-action.'
);

Competitor Analysis

$task = $client->createTask(
    'Research and analyze top 5 competitors in the project management software space. 
    Provide pricing comparison, feature matrix, and market positioning insights.'
);

πŸŽ“ Education & E-Learning

Quiz & Assessment Generator

$task = $client->createTask(
    'Create a 25-question multiple-choice quiz on PHP 8.2 features with explanations 
    for each answer. Include beginner, intermediate, and advanced difficulty levels.'
);

Personalized Learning Paths

$task = $client->createTask(
    "Based on student's current skill level in {$subject}, create a personalized 
    12-week learning roadmap with weekly goals, resources, and practice exercises."
);

πŸ”§ Development & Code Assistance

Code Review & Documentation

$fileResult = $client->createFile('legacy_code.php');
$client->uploadFileContent($fileResult['upload_url'], $codeContent, 'text/plain');

$task = $client->createTask(
    'Review this PHP code for: security vulnerabilities, performance issues, 
    best practices violations, and suggest improvements with code examples',
    ['attachments' => [TaskAttachment::fromFileId($fileResult['id'])]]
);

API Documentation Generator

$task = $client->createTask(
    'Generate comprehensive API documentation for our REST endpoints including: 
    request/response examples, authentication, error codes, and usage examples'
);

πŸ₯ Healthcare & Legal (Document Processing)

Medical Report Summarization

$task = $client->createTask(
    'Summarize this medical report into patient-friendly language, highlighting 
    key findings, recommendations, and next steps',
    ['attachments' => [TaskAttachment::fromFilePath('/path/to/medical_report.pdf')]]
);

Contract Analysis

$task = $client->createTask(
    'Analyze this contract and identify: key terms, obligations, potential risks, 
    important dates, and clauses that require legal review',
    ['attachments' => [TaskAttachment::fromFileId($contractFileId)]]
);

🌐 Multilingual Applications

Translation & Localization

$task = $client->createTask(
    'Translate this marketing copy into Spanish, French, German, and Japanese. 
    Maintain tone, cultural nuances, and marketing impact in each language.'
);

πŸ“§ Email Marketing Automation

Campaign Creation

$task = $client->createTask(
    'Create a 5-email drip campaign for new SaaS users: welcome email, feature 
    highlights, success stories, upgrade incentive, and feedback request. 
    Include subject lines and optimal sending schedule.'
);

οΏ½πŸ’‘ Code Examples & Tutorials

See the examples/ directory for complete working examples:

  • basic.php - Basic task creation and management
  • file-upload.php - File upload with attachments
  • webhook.php - Webhook setup and handling
  • laravel-routes.php - Laravel route examples
  • advanced-workflows.php - Complex multi-step AI workflows
  • error-handling.php - Comprehensive error handling patterns

πŸ§ͺ Testing & Quality Assurance

Running Tests

We take code quality seriously. The SDK includes a comprehensive test suite covering all major functionality:

# Run all tests
composer test

# Run tests with detailed output
composer test -- --verbose

# Run specific test file
./vendor/bin/phpunit tests/ManusAIClientTest.php

Code Coverage

Generate detailed code coverage reports to ensure reliability:

# Generate HTML coverage report
composer test-coverage

# View coverage in terminal
composer test -- --coverage-text

Continuous Integration

The SDK is tested against multiple PHP versions and Laravel versions to ensure compatibility:

  • PHP 8.2, 8.3, 8.4
  • Laravel 8.x, 9.x, 10.x, 11.x, 12.x
  • Multiple operating systems (Linux, macOS, Windows)

❓ Frequently Asked Questions (FAQ)

General Questions

Q: Is this SDK free to use?
A: Yes! The SDK is open-source and licensed under MIT. However, you'll need a Manus AI account and API key, which may have usage costs depending on your plan.

Q: What's the difference between this SDK and calling the API directly?
A: This SDK provides type-safe interfaces, automatic error handling, helper classes, Laravel integration, and comprehensive documentation. It saves you hundreds of lines of boilerplate code.

Q: Can I use this in production applications?
A: Absolutely! The SDK is production-ready, battle-tested, and includes comprehensive error handling and logging capabilities.

Q: Does this work with older PHP versions?
A: The SDK requires PHP 8.2+ to take advantage of modern PHP features like typed properties, enums, and improved type system.

Laravel-Specific Questions

Q: Do I need Laravel to use this SDK?
A: No! The SDK works perfectly in any PHP 8.2+ application. Laravel integration is optional but provides additional convenience features.

Q: How do I use this in Laravel Lumen?
A: Register the service provider manually in bootstrap/app.php:

$app->register(Tigusigalpa\ManusAI\Laravel\ManusAIServiceProvider::class);

Q: Can I use multiple API keys in one Laravel application?
A: Yes! Create multiple client instances with different API keys:

$client1 = new ManusAIClient('key-1');
$client2 = new ManusAIClient('key-2');

Technical Questions

Q: How do I handle rate limiting?
A: The SDK automatically includes retry logic for rate limit errors. You can also implement exponential backoff in your application layer.

Q: What file formats are supported for uploads?
A: Manus AI supports PDF, images (JPG, PNG, GIF), documents (DOC, DOCX), spreadsheets (XLS, XLSX), and text files. Check the official API documentation for the complete list.

Q: How long do tasks take to complete?
A: Task completion time varies based on complexity and model used. Simple tasks may complete in seconds, while complex analysis can take minutes. Use webhooks for real-time notifications.

Q: Can I cancel a running task?
A: Currently, the Manus AI API doesn't support task cancellation. However, you can delete completed tasks to clean up your task list.

Q: How do I handle errors and exceptions?
A: The SDK throws descriptive exceptions for all error conditions. Wrap your calls in try-catch blocks:

try {
    $task = $client->createTask('Your prompt');
} catch (\Exception $e) {
    Log::error('Manus AI Error: ' . $e->getMessage());
}

Performance & Optimization

Q: Which agent profile should I use?
A:

  • MANUS_1_6: Best balance of quality and speed (recommended for most use cases)
  • MANUS_1_6_LITE: Faster responses, lower cost (good for simple tasks)
  • MANUS_1_6_MAX: Maximum capability (complex reasoning and analysis)

Q: How can I reduce API costs?
A: Use the Lite model for simple tasks, batch similar requests, cache results when appropriate, and use precise prompts to avoid unnecessary iterations.

Q: Can I process multiple tasks in parallel?
A: Yes! Create multiple tasks asynchronously and use webhooks to get notified when each completes:

$tasks = [];
foreach ($prompts as $prompt) {
    $tasks[] = $client->createTask($prompt);
}

Integration Questions

Q: Can I integrate this with my existing CMS?
A: Yes! The SDK is framework-agnostic and can be integrated into WordPress, Drupal, Joomla, or any PHP-based CMS.

Q: Does this work with queued jobs?
A: Absolutely! Perfect for Laravel queues:

dispatch(new ProcessAITask($prompt));

Q: Can I use this in a REST API?
A: Yes! The SDK is perfect for building AI-powered REST APIs. See the Laravel route examples for implementation patterns.

πŸ”§ Troubleshooting Guide

Common Issues & Solutions

Issue: "Invalid API Key" Error

Solution:

  1. Verify your API key is correct in .env or configuration
  2. Ensure there are no extra spaces or quotes around the key
  3. Check that your Manus AI account is active
  4. Regenerate your API key from the Manus AI dashboard
// Test your API key
try {
    $client = new ManusAIClient('your-api-key');
    $tasks = $client->getTasks(['limit' => 1]);
    echo "βœ… API key is valid!\n";
} catch (\Exception $e) {
    echo "❌ Error: " . $e->getMessage() . "\n";
}

Issue: File Upload Fails

Solution:

  1. Check file size limits (typically 10MB max)
  2. Verify the file exists and is readable
  3. Ensure correct MIME type is specified
  4. Check your internet connection
// Debug file upload
$filePath = '/path/to/file.pdf';
if (!file_exists($filePath)) {
    die("File not found!");
}
if (!is_readable($filePath)) {
    die("File not readable!");
}
echo "File size: " . filesize($filePath) . " bytes\n";

Issue: Webhook Not Receiving Events

Solution:

  1. Ensure your webhook URL is publicly accessible (not localhost)
  2. Verify HTTPS is enabled (required for production)
  3. Check your server logs for incoming requests
  4. Test webhook endpoint manually with curl
# Test webhook endpoint
curl -X POST https://your-domain.com/webhook/manus-ai \
  -H "Content-Type: application/json" \
  -d '{"event":"task_stopped","data":{"task_id":"test"}}'

Issue: Task Takes Too Long

Solution:

  1. Use MANUS_1_6_LITE for faster responses
  2. Simplify your prompt to be more specific
  3. Break complex tasks into smaller subtasks
  4. Implement webhooks instead of polling

Issue: Composer Installation Fails

Solution:

# Clear Composer cache
composer clear-cache

# Update Composer itself
composer self-update

# Install with verbose output
composer require tigusigalpa/manus-ai-php -vvv

# Check PHP version
php -v  # Must be 8.2 or higher

Issue: Laravel Service Provider Not Loading

Solution:

# Clear Laravel caches
php artisan config:clear
php artisan cache:clear
php artisan route:clear

# Re-publish configuration
php artisan vendor:publish --tag=manus-ai-config --force

# Verify provider is registered
php artisan about

Getting Help

If you encounter issues not covered here:

  1. Check the Examples: Review the examples/ directory for working code
  2. Read API Docs: Visit Manus AI API Documentation
  3. Search Issues: Check GitHub Issues
  4. Ask the Community: Open a new issue with detailed information
  5. Contact Support: Email sovletig@gmail.com for direct assistance

Debug Mode

Enable detailed logging for troubleshooting:

// Enable Guzzle debug mode
$client = new ManusAIClient('your-api-key', [
    'debug' => true,  // Outputs all HTTP requests/responses
]);

⚑ Performance & Best Practices

Optimizing Your AI Workflows

1. Choose the Right Model

// For simple tasks - use Lite (faster, cheaper)
$task = $client->createTask('Summarize this text in 3 sentences', [
    'agentProfile' => AgentProfile::MANUS_1_6_LITE
]);

// For complex analysis - use Max (more capable)
$task = $client->createTask('Perform deep competitive analysis with market insights', [
    'agentProfile' => AgentProfile::MANUS_1_6_MAX
]);

// For balanced performance - use standard (recommended)
$task = $client->createTask('Generate blog post with SEO optimization', [
    'agentProfile' => AgentProfile::MANUS_1_6
]);

2. Write Effective Prompts

❌ Poor Prompt:

$task = $client->createTask('Write something about AI');

βœ… Excellent Prompt:

$task = $client->createTask(
    'Write a 500-word blog post about AI in healthcare. 
    Target audience: medical professionals. 
    Tone: professional yet accessible. 
    Include: 3 real-world examples, statistics, and a call-to-action. 
    SEO keywords: AI healthcare, medical AI, diagnostic automation.'
);

3. Implement Caching

// Cache frequently requested content
$cacheKey = 'manus_task_' . md5($prompt);

if (Cache::has($cacheKey)) {
    return Cache::get($cacheKey);
}

$result = $client->createTask($prompt);
Cache::put($cacheKey, $result, now()->addHours(24));

4. Use Webhooks for Long-Running Tasks

// ❌ Polling (inefficient)
do {
    sleep(5);
    $task = $client->getTask($taskId);
} while ($task['status'] !== 'completed');

// βœ… Webhooks (efficient)
$webhook = $client->createWebhook([
    'url' => 'https://your-app.com/webhook',
    'events' => ['task_stopped']
]);

5. Batch Processing

// Process multiple items efficiently
$taskIds = [];
foreach ($items as $item) {
    $result = $client->createTask("Process: {$item}");
    $taskIds[] = $result['task_id'];
}

// Handle results via webhook or batch retrieval

6. Error Handling & Retries

use Illuminate\Support\Facades\Retry;

$task = Retry::times(3)
    ->sleep(1000)
    ->catch(function ($e) {
        Log::warning('Manus AI retry: ' . $e->getMessage());
    })
    ->throw(function ($e) {
        Log::error('Manus AI failed after retries: ' . $e->getMessage());
    })
    ->call(function () use ($client, $prompt) {
        return $client->createTask($prompt);
    });

7. Monitor Credit Usage

// Track API costs
$task = $client->getTask($taskId);
$creditsUsed = $task['credit_usage'];

Log::info("Task {$taskId} used {$creditsUsed} credits");

// Alert on high usage
if ($creditsUsed > 100) {
    Notification::send($admin, new HighCreditUsageAlert($taskId));
}

Security Best Practices

1. Secure API Key Storage

// βœ… Use environment variables
$client = new ManusAIClient(env('MANUS_AI_API_KEY'));

// ❌ Never hardcode
$client = new ManusAIClient('sk-abc123...'); // DON'T DO THIS!

2. Validate User Input

// Sanitize prompts from user input
$userPrompt = strip_tags($request->input('prompt'));
$userPrompt = substr($userPrompt, 0, 5000); // Limit length

$task = $client->createTask($userPrompt);

3. Implement Rate Limiting

// Laravel rate limiting
Route::middleware('throttle:10,1')->post('/api/ai-task', function (Request $request) {
    return ManusAI::createTask($request->input('prompt'));
});

4. Webhook Signature Verification

// Verify webhook authenticity (implement based on your security needs)
public function handleWebhook(Request $request)
{
    $signature = $request->header('X-Manus-Signature');
    
    if (!$this->verifySignature($signature, $request->getContent())) {
        abort(403, 'Invalid signature');
    }
    
    // Process webhook...
}

🀝 Contributing to the Project

We love contributions! Whether you're fixing bugs, adding features, or improving documentation, your help makes this SDK better for everyone.

How to Contribute

1. Fork & Clone

# Fork the repository on GitHub, then:
git clone https://github.com/YOUR-USERNAME/manus-ai-php.git
cd manus-ai-php
composer install

2. Create a Feature Branch

git checkout -b feature/amazing-new-feature
# or
git checkout -b bugfix/fix-important-issue

3. Make Your Changes

  • Write clean, documented code
  • Follow PSR-12 coding standards
  • Add tests for new features
  • Update documentation as needed

4. Run Tests

# Ensure all tests pass
composer test

# Check code style
composer phpcs

# Fix code style automatically
composer phpcbf

5. Commit Your Changes

git add .
git commit -m "feat: Add amazing new feature"

# Use conventional commit messages:
# feat: New feature
# fix: Bug fix
# docs: Documentation changes
# test: Test additions/changes
# refactor: Code refactoring

6. Push & Create Pull Request

git push origin feature/amazing-new-feature

Then open a Pull Request on GitHub with:

  • Clear description of changes
  • Link to related issues
  • Screenshots (if applicable)
  • Test results

Contribution Guidelines

Code Standards

  • PHP 8.2+: Use modern PHP features (typed properties, enums, etc.)
  • Type Safety: Always use type hints and return types
  • Documentation: PHPDoc blocks for all public methods
  • Testing: Maintain 100% code coverage for new features
  • PSR-12: Follow PHP-FIG coding standards

What We're Looking For

🎯 High Priority:

  • Bug fixes with test cases
  • Performance improvements
  • Documentation enhancements
  • New helper methods
  • Additional examples

πŸ’‘ Feature Ideas:

  • Streaming response support
  • Advanced caching strategies
  • Batch operation helpers
  • Additional Laravel integrations
  • Symfony bundle support

πŸ“š Documentation:

  • Tutorial articles
  • Video guides
  • Translation to other languages
  • Real-world case studies

Code Review Process

  1. Automated Checks: CI/CD runs tests and code quality checks
  2. Maintainer Review: Core team reviews code and provides feedback
  3. Iteration: Address feedback and update PR
  4. Merge: Once approved, your contribution is merged!

Development Setup

# Install dependencies
composer install

# Copy environment file
cp .env.example .env

# Add your test API key
echo "MANUS_AI_API_KEY=your-test-key" >> .env

# Run tests
composer test

# Run tests with coverage
composer test-coverage

# Check code style
composer phpcs

# Fix code style
composer phpcbf

Running Examples

# Test basic functionality
php examples/basic.php

# Test file uploads
php examples/file-upload.php

# Test webhooks
php examples/webhook.php

Community Guidelines

  • Be Respectful: Treat everyone with respect and kindness
  • Be Constructive: Provide helpful feedback and suggestions
  • Be Patient: Maintainers are volunteers with limited time
  • Be Collaborative: Work together to find the best solutions

Recognition

Contributors are recognized in:

  • GitHub contributors page
  • Release notes
  • Project documentation
  • Special thanks section

Questions?

πŸ—ΊοΈ Roadmap & Future Plans

We're constantly improving the SDK based on community feedback and emerging AI capabilities. Here's what's on the horizon:

πŸš€ Upcoming Features (v2.0)

Q1 2026:

  • ✨ Streaming Responses: Real-time task output streaming for interactive applications
  • πŸ”„ Async/Promise Support: Non-blocking operations with ReactPHP integration
  • πŸ“Š Advanced Analytics: Built-in usage tracking and cost optimization tools
  • 🎨 Response Formatters: Automatic parsing of JSON, Markdown, and structured outputs

Q2 2026:

  • πŸ”Œ Symfony Bundle: Native Symfony framework integration
  • 🌐 WordPress Plugin: Easy integration for WordPress developers
  • πŸ“± Mobile SDK Companion: Complementary mobile SDK documentation
  • 🧩 Plugin System: Extensible architecture for custom integrations

Q3 2026:

  • πŸ€– AI Workflow Builder: Visual workflow designer for complex AI pipelines
  • πŸ“ˆ Performance Dashboard: Real-time monitoring and optimization insights
  • πŸ” Enhanced Security: OAuth support and advanced authentication options
  • 🌍 Multi-Region Support: Automatic region selection for optimal performance

πŸ’‘ Community Requests

Vote on features you'd like to see:

  • GraphQL API support
  • Batch file upload optimization
  • Custom model fine-tuning integration
  • Advanced prompt templates library
  • Integration with popular CMS platforms
  • Docker container for local development

Want to influence the roadmap? Open a feature request or vote on existing proposals!

πŸ“Š Comparison with Alternatives

Why Choose Manus AI PHP SDK?

Feature Manus AI PHP SDK Direct API Calls Other SDKs
Type Safety βœ… Full PHP 8.2+ types ❌ Manual typing ⚠️ Partial
Laravel Integration βœ… Native support ❌ Manual setup ⚠️ Limited
Error Handling βœ… Comprehensive ❌ Manual ⚠️ Basic
Helper Classes βœ… Rich utilities ❌ None ⚠️ Few
Documentation βœ… Extensive ⚠️ API docs only ⚠️ Limited
Active Maintenance βœ… Regular updates N/A ⚠️ Varies
Test Coverage βœ… 100% ❌ N/A ⚠️ Varies
Community Support βœ… Active ❌ None ⚠️ Limited
Examples & Tutorials βœ… Comprehensive ❌ None ⚠️ Basic
Webhook Helpers βœ… Built-in ❌ Manual ❌ None

πŸ“„ License

This project is open-source and licensed under the MIT License - see the LICENSE file for complete details.

What This Means For You

βœ… Commercial Use: Use in commercial projects without restrictions
βœ… Modification: Modify the code to fit your needs
βœ… Distribution: Distribute your modified versions
βœ… Private Use: Use privately without disclosure
βœ… No Warranty: Provided "as-is" without warranty

πŸ”— Important Links & Resources

Official Resources

SDK Resources

Connect:

Other Projects:

πŸ™ Acknowledgments & Credits

Special Thanks

Manus AI Team - For creating an exceptional AI agent platform and providing excellent API documentation

PHP Community - For continuous inspiration and best practices that shaped this SDK

Laravel Community - For feedback on Laravel integration features

Early Adopters - Developers who tested early versions and provided invaluable feedback

Contributors - Everyone who submitted pull requests, reported issues, or improved documentation

Built With

  • 🐘 PHP 8.2+ - Modern PHP features and performance
  • 🌐 Guzzle HTTP - Reliable HTTP client for API communication
  • 🎨 Laravel - Optional but powerful framework integration
  • πŸ§ͺ PHPUnit - Comprehensive testing framework
  • πŸ“ PHPStan - Static analysis for code quality
  • 🎯 PHP-CS-Fixer - Code style consistency

Inspired By

This SDK follows best practices from leading PHP packages:

  • Laravel's elegant API design
  • Symfony's robust architecture
  • Guzzle's flexible HTTP handling
  • Stripe PHP's developer experience

πŸš€ Start Building Today!

Ready to transform your PHP applications with AI? Get started in 3 simple steps:

# 1. Install the SDK
composer require tigusigalpa/manus-ai-php

# 2. Set your API key
export MANUS_AI_API_KEY="your-api-key-here"

# 3. Create your first AI task
php -r "require 'vendor/autoload.php'; 
use Tigusigalpa\ManusAI\ManusAIClient;
\$client = new ManusAIClient(getenv('MANUS_AI_API_KEY'));
\$result = \$client->createTask('Hello, AI world!');
echo 'Task created: ' . \$result['task_url'] . PHP_EOL;"

Join Our Growing Community

  • ⭐ Star the repo on GitHub to show your support
  • πŸ”” Watch for updates to stay informed about new features
  • 🀝 Contribute to make the SDK even better
  • πŸ“’ Share with fellow PHP developers

Empowering PHP developers to build intelligent applications

⬆ Back to Top

Keywords for SEO

PHP AI SDK, Manus AI PHP, Laravel AI integration, PHP artificial intelligence, AI agent PHP, PHP machine learning, AI automation PHP, PHP chatbot SDK, Laravel AI package, PHP AI library, Manus AI wrapper, PHP AI API, intelligent PHP applications, AI-powered PHP, PHP AI development, Laravel AI tools, PHP AI framework, automated AI tasks PHP, PHP AI integration, Laravel machine learning