定制 nicodemuz/php-getimg.ai 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

nicodemuz/php-getimg.ai

Composer 安装命令:

composer require nicodemuz/php-getimg.ai

包简介

PHP SDK for GetImg.ai image generation service.

README 文档

README

License PHP Version Composer

nicodemuz/php-getimg.ai is a modern, lightweight PHP library designed to integrate seamlessly with the GetImg.ai image generation API. Quickly generate stunning AI-powered images for your projects with just a few lines of code.

This package is currently under development. There is only support for text-to-image generation & inpainting. Pull requests for other features are welcome.

Features 🚀

  • PSR-18 and PSR-17 Compatibility: Fully compliant with PSR-18 (HTTP Client) and PSR-17 (HTTP Factories) standards, ensuring seamless integration with any compatible HTTP client and factory implementation.
  • Comprehensive API Coverage: Access all GetImg.ai image generation features.
  • Flexible Configuration: Customize HTTP client, request factories, and other dependencies to suit your project.
  • Lightweight: Minimal dependencies for fast and efficient performance.

Installation 💻

Install the package via Composer:

composer require nicodemuz/php-getimg.ai

Installation 💻

Install the package via Composer:

composer require nicodemuz/php-getimg.ai

Installing PSR-17 and PSR-18 dependencies

To use this library, you'll need PSR-17 (HTTP Factories) and PSR-18 (HTTP Client) compatible packages. If you don't already have them, you can install popular implementations such as:

  1. Guzzle (for PSR-18) and Nyholm/psr7 (for PSR-17):

    composer require guzzlehttp/guzzle nyholm/psr7
  2. Symfony HTTP Client (alternative for PSR-18) and Symfony HTTP Factories (for PSR-17):

    composer require symfony/http-client symfony/psr-http-message-bridge

After installation, initialize the required dependencies in your project as shown in the usage example.

Usage 📖

Basic Example

<?php

require 'vendor/autoload.php';

use Nicodemuz\PhpGetImgAi\GetImgAiClient;
use Nicodemuz\PhpGetImgAi\Request\TextToImageRequest;
use GuzzleHttp\Client as HttpClient;
use Nyholm\Psr7\Factory\Psr17Factory;

// Initialize the required dependencies
$httpClient = new HttpClient();
$requestFactory = new Psr17Factory();
$streamFactory = new Psr17Factory();

// Initialize the GetImgAiClient with your API key
$apiKey = 'your-api-key-here';
$getImgClient = new GetImgAiClient($apiKey, $httpClient, $requestFactory, $streamFactory);

try {
    // Create a request for text-to-image generation
    $textToImageRequest = new TextToImageRequest(
        prompt: 'A futuristic city skyline at sunset, cyberpunk style',
        model: 'flux-schnell',
        width: 1024,
        height: 1024,
        steps: 4,
        seed: null, // Optional seed for reproducibility
        outputFormat: 'jpeg',
        responseFormat: 'url'
    );

    // Generate the image
    $response = $getImgClient->textToImage($textToImageRequest);

    // Output the results
    echo "Image URL: " . $response->getUrl() . PHP_EOL;
    echo "Seed Used: " . $response->getSeed() . PHP_EOL;
    echo "Cost: $" . $response->getCost() . PHP_EOL;

    // Optionally, download the image
    $imageData = file_get_contents($response->getUrl());
    file_put_contents('generated_image.jpeg', $imageData);
    echo "Image saved as 'generated_image.jpeg'." . PHP_EOL;

} catch (Exception $e) {
    // Handle errors
    echo "Error: " . $e->getMessage() . PHP_EOL;
}

Requirements 📋

  • PHP 8.3 or higher
  • Composer

Contributing 🤝

Contributions are welcome! To contribute:

  1. Fork the repository.
  2. Create a new feature branch.
  3. Submit a pull request with a clear description of your changes.

License 📜

This library is open-sourced software licensed under the MIT License.

Support & Feedback ✉️

If you encounter issues or have suggestions, feel free to open an issue.

Authors

🌟 Happy Generating!

nicodemuz/php-getimg.ai 适用场景与选型建议

nicodemuz/php-getimg.ai 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 640 次下载、GitHub Stars 达 2, 最近一次更新时间为 2024 年 12 月 02 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 nicodemuz/php-getimg.ai 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 640
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 6
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-12-02