1. Go to this page and download the library: Download aimatchfun/laravel-runware 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/ */
aimatchfun / laravel-runware example snippets
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();
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]);
}
}
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;
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;
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
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
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();
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());
}