PHPackages                             vedanshi-shethia/ai-banner-generator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. vedanshi-shethia/ai-banner-generator

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

vedanshi-shethia/ai-banner-generator
====================================

Laravel package to generate website banners using Gemini AI

v1.0.0(4mo ago)01MITPHPPHP ^8.1

Since Dec 31Pushed 4mo agoCompare

[ Source](https://github.com/vedanshi-shethia/ai-banner-generator)[ Packagist](https://packagist.org/packages/vedanshi-shethia/ai-banner-generator)[ RSS](/packages/vedanshi-shethia-ai-banner-generator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

🎨 AI Banner Generator (Laravel Package)
=======================================

[](#-ai-banner-generator-laravel-package)

A **driver-based, extensible Laravel package** for generating high-quality website banners using AI image models (Gemini, OpenAI, or custom providers).

This package abstracts **AI image generation**, **prompt building**, **image handling**, and **storage**, while allowing developers to **plug in their own AI drivers** without touching core logic.

---

✨ Features
----------

[](#-features)

- 🔌 **Driver-based architecture** (Gemini, OpenAI, Null, Custom)
- 🧠 Centralized **AI model management**
- 🖼️ Supports **image-to-image generation**
- 🧩 Fully **extensible with custom drivers**
- 🧼 Automatic **temporary file cleanup**
- 📦 Clean separation of concerns (Service, Drivers, Helpers)
- 🛡️ Safe base64 image validation before storage

---

📦 Installation
--------------

[](#-installation)

### 1️⃣ Install via Composer

[](#1️⃣-install-via-composer)

```
composer require vedanshi/ai-banner-generator
```

---

### 2️⃣ Publish Configuration

[](#2️⃣-publish-configuration)

```
php artisan vendor:publish --tag=ai-banner-generator
```

This will create:

```
config/ai-banner-generator.php
```

---

### 3️⃣ Configure Storage

[](#3️⃣-configure-storage)

Ensure your output disk is publicly accessible.

```
php artisan storage:link
```

---

### 🔑 Environment variables

[](#-environment-variables)

```
AI_BANNER_DRIVER = 'driver_name'

# Storage
GEMINI_INPUT_DISK=local
GEMINI_OUTPUT_DISK=public
```

---

🧠 Storage Design (Important)
----------------------------

[](#-storage-design-important)

This package follows **industry best practices**:

TypeDiskVisibilityInput images`local`🔒 PrivateGenerated banners`public`🌍 Public```
storage/
├── app/
│   ├── private/
│   │   └── banner/input/
│   └── public/
│       └── banner/output/

```

---

⚙️ Configuration (`config/ai-banner-generator.php`)
---------------------------------------------------

[](#️-configuration-configai-banner-generatorphp)

```
return [

    /*
    |--------------------------------------------------------------------------
    | Driver Configuration
    |--------------------------------------------------------------------------
    */

    'driver' => env('AI_BANNER_DRIVER', 'gemini'),

    'drivers' => [

        'gemini' => [
            'model'   => env('GEMINI_MODEL', 'gemini-2.5-flash-image'),
            'api_key' => env('GEMINI_API_KEY'),
        ],

        'openai' => [
            'model'   => env('OPENAI_MODEL', 'gpt-4o-mini'),
            'api_key' => env('OPENAI_API_KEY'),
        ],

    ],

    /*
    |--------------------------------------------------------------------------
    | Storage Configuration
    |--------------------------------------------------------------------------
    */

    'disks' => [
        'input'  => env('BANNER_INPUT_IMAGE_DISK', 'local'),   // private
        'output' => env('BANNER_OUTPUT_IMAGE_DISK', 'public'), // public
    ],

    'paths' => [

        // Input uploads
        'front' => 'banner/front',
        'back' => 'banner/back',
        'reference' => 'banner/ref',

        // Output (generated banners)
        'output' => 'banner/output',
    ],

    'cleanup' => [
        'enabled' => true,
    ],

    /*
    |--------------------------------------------------------------------------
    | Output Configuration
    |--------------------------------------------------------------------------
    */
    'output' => [
        'format' => 'png',
        'allowed_mime_types' => ['image/png', 'image/jpeg'],
    ],

];
```

📌 **Important**

- Users switch models **only via config**
- No runtime config injection
- Drivers stay clean and predictable

---

🧠 Architecture Overview
-----------------------

[](#-architecture-overview)

```
Controller / App
     ↓
BannerService
     ↓
BannerDriverFactory
     ↓
Driver (Gemini / OpenAI / Custom)
     ↓
AI Model

```

### Key Components

[](#key-components)

LayerResponsibility**Service**Business flow**Factory**Driver resolution**Driver**AI interaction**Helpers**Image / prompt handling**Storage**File persistence---

🧩 Banner Generation Flow
------------------------

[](#-banner-generation-flow)

1. Input images are uploaded
2. Images are loaded &amp; converted to Base64
3. Prompt is generated
4. Driver is resolved
5. AI generates banner
6. Image is validated &amp; stored
7. Temporary files are cleaned
8. Public URL is returned

---

🚀 Usage
-------

[](#-usage)

### 1️⃣ Sync Generation (Facade)

[](#1️⃣-sync-generation-facade)

```
use Vedanshi\Banner\Facades\Banner;
use Vedanshi\Banner\Http\Requests\BannerGenerationRequest;

function (BannerGenerationRequest $request) {
    $result = Banner::generate($request->payload());
}
```

Returns a **public URL** of the generated banner.

---

### 2️⃣ Async Generation (Queue)

[](#2️⃣-async-generation-queue)

```
use Vedanshi\Banner\Jobs\BannerGenerationJob;
use Vedanshi\Banner\Http\Requests\BannerGenerationRequest;

function (BannerGenerationRequest $request) {
    BannerGenerationJob::dispatch($request->payload());
}
```

✅ Ideal for:

- Heavy image processing
- High-traffic systems
- Background workflows

---

🧾 Expected Payload Structure
----------------------------

[](#-expected-payload-structure)

```
[
    'front_image' => string,        // path on input disk
    'back_image' => string,         // path on input disk
    'transparent_image' => string,  // path on input disk
    'product_name' => string,
]
```

> ⚠️ Do NOT pass temp paths (`php/tmp`). Files must be stored first using Laravel storage.

---

🧹 Automatic Cleanup
-------------------

[](#-automatic-cleanup)

- Input images are **deleted immediately after successful generation**
- Cleanup is **retry-safe**
- Cleanup can be disabled via config

```
'cleanup' => [
    'enabled' => false,
],
```

---

🖼️ Image Handling &amp; Safety
------------------------------

[](#️-image-handling--safety)

Before storing the generated image:

- `data:image/*;base64,...` is handled
- Strict Base64 decoding
- Image validity is verified
- MIME type is validated

```
ImageStorage::store($base64);
```

This prevents:

- Invalid data storage
- Corrupt images
- Security risks

---

🔌 Built-in Drivers
------------------

[](#-built-in-drivers)

### Gemini Driver

[](#gemini-driver)

```
new GeminiDriver($config);
```

Uses **Prism** internally for image generation.

---

### OpenAI Driver

[](#openai-driver)

```
new OpenAIDriver($config);
```

Abstracted behind the same interface.

---

### Null Driver

[](#null-driver)

```
new NullDriver($config);
```

Useful for:

- Testing
- CI pipelines
- Fallback mode

---

🧩 Creating a Custom Driver (User Extensible)
--------------------------------------------

[](#-creating-a-custom-driver-user-extensible)

### 1️⃣ Implement the Contract

[](#1️⃣-implement-the-contract)

```
use Vedanshi\Banner\Contracts\BannerDriver;

class MyDriver implements BannerDriver
{
    public function __construct(protected array $config) {}

    public function generate(string $prompt, array $images): string
    {
        // Custom AI logic
        return $base64;
    }
}
```

---

### 2️⃣ Register the Driver

[](#2️⃣-register-the-driver)

```
use Vedanshi\Banner\Factory\BannerDriverFactory;

BannerDriverFactory::extend('my-driver', function ($config) {
    return new MyDriver($config);
});
```

---

### 3️⃣ Add Key in .env

[](#3️⃣-add-key-in-env)

```
AI_BANNER_DRIVER = 'my-driver'
```

🎉 Done — no core code touched.

---

🧠 Why This Design Works
-----------------------

[](#-why-this-design-works)

- ✔ **Manager-controlled configuration**
- ✔ No runtime config injection
- ✔ Clean SOLID design
- ✔ Laravel-style driver extension
- ✔ Production-ready

This is the **same architecture Laravel uses for Cache, Queue, Mail, and Filesystems**.

---

🧪 Testing
---------

[](#-testing)

Use the `null` driver:

```
AI_BANNER_DRIVER = 'null'
```

This avoids API calls and allows fast testing.

---

📌 Summary
---------

[](#-summary)

- AI-agnostic banner generation
- Driver-based extensibility
- Safe image handling
- Clean separation of concerns
- Enterprise-grade Laravel architecture

---

📄 License
---------

[](#-license)

MIT License

---

🙌 Credits
---------

[](#-credits)

Developed by **Vedanshi Shethia**

---

🤝 Contributing
--------------

[](#-contributing)

Pull requests are welcome. For major changes, please open an issue first to discuss improvements.

---

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance76

Regular maintenance activity

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

132d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5030acb1da7bad73da63f71a61b3b781b6e8be5ccb140a6b207c20f4309c6709?d=identicon)[vedanshi-shethia](/maintainers/vedanshi-shethia)

---

Top Contributors

[![vedanshi-shethia](https://avatars.githubusercontent.com/u/195996636?v=4)](https://github.com/vedanshi-shethia "vedanshi-shethia (16 commits)")

### Embed Badge

![Health badge](/badges/vedanshi-shethia-ai-banner-generator/health.svg)

```
[![Health](https://phpackages.com/badges/vedanshi-shethia-ai-banner-generator/health.svg)](https://phpackages.com/packages/vedanshi-shethia-ai-banner-generator)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[illuminate/pipeline

The Illuminate Pipeline package.

9446.6M213](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10532.5M862](/packages/illuminate-pagination)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[spatie/laravel-mix-preload

Add preload and prefetch links based your Mix manifest

169176.0k2](/packages/spatie-laravel-mix-preload)[mrmarchone/laravel-auto-crud

Laravel Auto CRUD helps you streamline development and save time.

28711.8k2](/packages/mrmarchone-laravel-auto-crud)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
