Download the PHP package vedanshi-shethia/ai-banner-generator without Composer
On this page you can find all versions of the php package vedanshi-shethia/ai-banner-generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download vedanshi-shethia/ai-banner-generator
More information about vedanshi-shethia/ai-banner-generator
Files in vedanshi-shethia/ai-banner-generator
Package ai-banner-generator
Short Description Laravel package to generate website banners using Gemini AI
License MIT
Informations about the package ai-banner-generator
๐จ 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
- ๐ 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
1๏ธโฃ Install via Composer
2๏ธโฃ Publish Configuration
This will create:
3๏ธโฃ Configure Storage
Ensure your output disk is publicly accessible.
๐ Environment variables
๐ง Storage Design (Important)
This package follows industry best practices:
| Type | Disk | Visibility |
|---|---|---|
| Input images | local |
๐ Private |
| Generated banners | public |
๐ Public |
โ๏ธ Configuration (config/ai-banner-generator.php)
๐ Important
- Users switch models only via config
- No runtime config injection
- Drivers stay clean and predictable
๐ง Architecture Overview
Key Components
| Layer | Responsibility |
|---|---|
| Service | Business flow |
| Factory | Driver resolution |
| Driver | AI interaction |
| Helpers | Image / prompt handling |
| Storage | File persistence |
๐งฉ Banner Generation Flow
- Input images are uploaded
- Images are loaded & converted to Base64
- Prompt is generated
- Driver is resolved
- AI generates banner
- Image is validated & stored
- Temporary files are cleaned
- Public URL is returned
๐ Usage
1๏ธโฃ Sync Generation (Facade)
Returns a public URL of the generated banner.
2๏ธโฃ Async Generation (Queue)
โ Ideal for:
- Heavy image processing
- High-traffic systems
- Background workflows
๐งพ Expected Payload Structure
โ ๏ธ Do NOT pass temp paths (
php/tmp). Files must be stored first using Laravel storage.
๐งน Automatic Cleanup
- Input images are deleted immediately after successful generation
- Cleanup is retry-safe
- Cleanup can be disabled via config
๐ผ๏ธ Image Handling & Safety
Before storing the generated image:
data:image/*;base64,...is handled- Strict Base64 decoding
- Image validity is verified
- MIME type is validated
This prevents:
- Invalid data storage
- Corrupt images
- Security risks
๐ Built-in Drivers
Gemini Driver
Uses Prism internally for image generation.
OpenAI Driver
Abstracted behind the same interface.
Null Driver
Useful for:
- Testing
- CI pipelines
- Fallback mode
๐งฉ Creating a Custom Driver (User Extensible)
1๏ธโฃ Implement the Contract
2๏ธโฃ Register the Driver
3๏ธโฃ Add Key in .env
๐ Done โ no core code touched.
๐ง 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
Use the null driver:
This avoids API calls and allows fast testing.
๐ Summary
- AI-agnostic banner generation
- Driver-based extensibility
- Safe image handling
- Clean separation of concerns
- Enterprise-grade Laravel architecture
๐ License
MIT License
๐ Credits
Developed by Vedanshi Shethia
๐ค Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss improvements.
All versions of ai-banner-generator with dependencies
illuminate/support Version ^9.0|^10.0|^11.0|^12.0
prism-php/prism Version ^0.99