承接 aimatchfun/laravel-runware 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

aimatchfun/laravel-runware

Composer 安装命令:

composer require aimatchfun/laravel-runware

包简介

A Laravel wrapper for the PHP Runware SDK - AI image generation made easy

README 文档

README

Latest Stable Version Total Downloads License

A Laravel wrapper for the PHP Runware SDK, providing a simple and elegant way to integrate Runware AI services into your Laravel applications.

Features

  • 🚀 Easy integration with Laravel
  • 🎨 Full support for Runware AI image generation capabilities
  • 🖼️ Inpainting: Selective image editing by modifying specific regions
  • ⚙️ Simple configuration via environment variables
  • 🔧 Service Provider and Facade included
  • 📦 Compatible with Laravel 12.x

Requirements

  • PHP ^8.4
  • Laravel ^12.0
  • A valid Runware API key

Installation

You can install the package via Composer:

composer require aimatchfun/laravel-runware

Configuration

After installation, publish the configuration file:

php artisan vendor:publish --provider="AiMatchFun\LaravelRunware\LaravelRunwareServiceProvider"

This will create a config/runware.php configuration file in your application.

Add your Runware API key to your .env file:

RUNWARE_API_KEY=your-api-key-here

Usage

Using the Facades

The package provides two facades: RunwareImageInference and RunwareInpainting. You can use them directly:

use RunwareImageInference;
use RunwareInpainting;
use AiMatchFun\PhpRunwareSDK\RunwareModel;
use AiMatchFun\PhpRunwareSDK\OutputType;

// Example: Generate an image using ImageInference
$imageUrl = RunwareImageInference::positivePrompt('A beautiful sunset over the mountains')
    ->negativePrompt('blur, distortion')
    ->width(512)
    ->height(512)
    ->model(RunwareModel::REAL_DREAM_SDXL_PONY_14)
    ->outputType(OutputType::URL)
    ->run();

// Example: Inpainting
$inpaintedImage = RunwareInpainting::seedImage('image-uuid')
    ->maskImage('mask-uuid')
    ->positivePrompt('a serene beach at sunset')
    ->strength(0.8)
    ->run();

Using Dependency Injection

You can also inject the Runware instance directly:

use AiMatchFun\PhpRunwareSDK\ImageInference;
use AiMatchFun\PhpRunwareSDK\Inpainting;
use AiMatchFun\PhpRunwareSDK\RunwareModel;
use AiMatchFun\PhpRunwareSDK\OutputType;

class ImageController extends Controller
{
    public function __construct(
        private ImageInference $runware,
        private Inpainting $inpainting
    ) {}

    public function generate()
    {
        $imageUrl = $this->runware
            ->positivePrompt('A futuristic cityscape')
            ->negativePrompt('blur')
            ->model(RunwareModel::REAL_DREAM_SDXL_PONY_14)
            ->outputType(OutputType::URL)
            ->run();

        return response()->json(['imageUrl' => $imageUrl]);
    }
}

Using the Service Container

use AiMatchFun\PhpRunwareSDK\RunwareModel;
use AiMatchFun\PhpRunwareSDK\OutputType;

// ImageInference
$runware = app('runware.imageInference');
$imageUrl = $runware->positivePrompt('A magical forest')
    ->negativePrompt('blur')
    ->model(RunwareModel::REAL_DREAM_SDXL_PONY_14)
    ->outputType(OutputType::URL)
    ->run();

// Inpainting
$inpainting = app('runware.inpainting');
$inpaintedImage = $inpainting->seedImage('image-uuid')
    ->maskImage('mask-uuid')
    ->positivePrompt('A serene beach at sunset')
    ->negativePrompt('blur, distortion')
    ->strength(0.8)
    ->run();

Available Methods

This package provides access to all methods available in the PHP Runware SDK. Some of the main features include:

  • Text-to-Image: Create AI-generated images from text prompts
  • Inpainting: Selective image editing by modifying specific regions of an image
  • Image Enhancement: Upscale and enhance existing images
  • Background Removal: Remove backgrounds from images
  • Image-to-Image: Transform images based on prompts
  • ControlNet: Advanced image generation with control
  • And many more...

For a complete list of available methods and their parameters, please refer to the PHP Runware SDK documentation.

Examples

Basic Image Generation (Text-to-Image)

use RunwareImageInference;
use AiMatchFun\PhpRunwareSDK\RunwareModel;
use AiMatchFun\PhpRunwareSDK\OutputType;



$imageUrl = RunwareImageInference::positivePrompt('A serene lake with mountains in the background')
    ->negativePrompt('blur, distortion')
    ->width(1024)
    ->height(1024)
    ->model(RunwareModel::REAL_DREAM_SDXL_PONY_14)
    ->outputType(OutputType::URL)
    ->numberResults(4)
    ->run();

echo $imageUrl;

Inpainting

Inpainting allows you to selectively edit specific regions of an image by providing a seed image and a mask image:

use RunwareInpainting;
use AiMatchFun\PhpRunwareSDK\RunwareModel;
use AiMatchFun\PhpRunwareSDK\OutputType;

$inpaintedImage = RunwareInpainting::seedImage('59a2edc2-45e6-429f-be5f-7ded59b92046') // Image UUID or URL
    ->maskImage('5988e195-8100-4b91-b07c-c7096d0861aa') // Mask UUID or URL
    ->positivePrompt('a serene beach at sunset')
    ->negativePrompt('blur, distortion')
    ->strength(0.8) // Strength of the inpainting effect (0.0 to 1.0)
    ->maskMargin(64) // Extra context pixels around masked region (32-128)
    ->model(RunwareModel::REAL_DREAM_SDXL_PONY_14)
    ->width(1024)
    ->height(1024)
    ->outputType(OutputType::URL)
    ->run();

echo $inpaintedImage;

Inpainting Parameters:

  • seedImage(): The original image you wish to edit (UUID or URL)
  • maskImage(): Defines the area to be modified (UUID or URL)
  • positivePrompt(): Describes the desired outcome for the masked area
  • strength(): Strength of the inpainting effect (0.0 to 1.0, default: 0.8)
  • maskMargin(): Adds extra context pixels around the masked region (32-128 pixels)

For more details about inpainting, see the Runware Inpainting Documentation.

Image Upload

You can upload images to Runware for use in various operations. The package provides two methods for uploading images:

Upload from Local File Path:

use RunwareImageUpload;

// Upload an image from a local file path (automatically converts to base64)
$imageUUID = RunwareImageUpload::uploadFromLocalPath('/path/to/image.jpg')
    ->run();

echo $imageUUID; // Use this UUID in inpainting or other image operations

Upload from URL:

use RunwareImageUpload;

// Upload an image from a public URL
$imageUUID = RunwareImageUpload::uploadFromURL('https://example.com/image.jpg')
    ->run();

echo $imageUUID; // Use this UUID in inpainting or other image operations

Upload Methods:

  • uploadFromLocalPath(string $path): Upload an image from a local file path. The file is automatically converted to base64 format.
  • uploadFromURL(string $url): Upload an image from a public URL.
  • The uploaded image can be referenced by its UUID in subsequent operations like inpainting, image enhancement, etc.

Using Dependency Injection:

use AiMatchFun\PhpRunwareSDK\ImageUpload;

$imageUpload = app('runware.imageUpload');

// From local path
$imageUUID = $imageUpload->uploadFromLocalPath('/path/to/image.jpg')
    ->run();

// From URL
$imageUUID = $imageUpload->uploadFromURL('https://example.com/image.jpg')
    ->run();

For more details about image upload, see the Runware Image Upload Documentation.

Error Handling

The package throws exceptions for API errors. It's recommended to wrap your calls in try-catch blocks:

use RunwareImageInference;
use AiMatchFun\PhpRunwareSDK\RunwareModel;
use AiMatchFun\PhpRunwareSDK\OutputType;
use Illuminate\Support\Facades\Log;

try {
    $imageUrl = RunwareImageInference::positivePrompt('A beautiful landscape')
        ->negativePrompt('blur')
        ->model(RunwareModel::REAL_DREAM_SDXL_PONY_14)
        ->outputType(OutputType::URL)
        ->run();
} catch (\Exception $e) {
    // Handle the error
    Log::error('Runware API error: ' . $e->getMessage());
}

Testing

When writing tests for code that uses this package, you can mock the Runware facade:

use RunwareImageInference;
use RunwareInpainting;

// Mock ImageInference
RunwareImageInference::shouldReceive('positivePrompt')
    ->once()
    ->with('Test prompt')
    ->andReturnSelf();

RunwareImageInference::shouldReceive('run')
    ->once()
    ->andReturn('https://example.com/test-image.jpg');

// Mock Inpainting
RunwareInpainting::shouldReceive('seedImage')
    ->once()
    ->with('image-uuid')
    ->andReturnSelf();

RunwareInpainting::shouldReceive('run')
    ->once()
    ->andReturn('https://example.com/inpainted-image.jpg');

For more detailed testing examples, see the tests documentation.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This package is open-sourced software licensed under the MIT license.

Credits

Support

If you encounter any issues or have questions, please open an issue on GitHub.

See Also

aimatchfun/laravel-runware 适用场景与选型建议

aimatchfun/laravel-runware 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 520 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 12 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「sdk」 「laravel」 「ai」 「artificial-intelligence」 「image-generation」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 aimatchfun/laravel-runware 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 aimatchfun/laravel-runware 我们能提供哪些服务?
定制开发 / 二次开发

基于 aimatchfun/laravel-runware 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 520
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 28
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-12-08