Download the PHP package fahimhossain/laravel-ai-tryon without Composer
On this page you can find all versions of the php package fahimhossain/laravel-ai-tryon. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download fahimhossain/laravel-ai-tryon
More information about fahimhossain/laravel-ai-tryon
Files in fahimhossain/laravel-ai-tryon
Package laravel-ai-tryon
Short Description A reusable Laravel package that adds AI-powered ecommerce virtual try-on previews.
License MIT
Informations about the package laravel-ai-tryon
Laravel AI Try-On
A reusable Laravel Composer package that adds an ecommerce "Try Out" button and modal to product detail pages. Shoppers upload their own photo, the package sends that photo plus the product image to an AI image-editing provider, and the generated virtual try-on preview is displayed in the modal.
The default provider is Google Gemini image generation through the Gemini API. Model names are configuration values, so you can use Nano Banana / Gemini Flash Image variants, newer Gemini image models, OpenAI, Replicate, or your own provider implementation without changing application code.
Installation
Publish the package files:
Or publish everything at once:
Environment
Google currently documents Gemini image generation through generateContent with text and inline image parts. Nano Banana model names can change, so keep GEMINI_IMAGE_MODEL in your environment or config rather than hardcoding a provider class.
Blade Usage
Place the component below your product image:
Supported product types are configurable and include shirt, t-shirt, pant, cap, dress, shoes, accessory, and other.
The component renders a button, upload modal, selected-photo preview, loading state, generated image, and clear error messages. It uses plain JavaScript and CSS published to public/vendor/ai-tryon.
Configuration
Publish config/ai-tryon.php and update:
To add a custom provider, bind your implementation to:
The provider must return a FahimHossain\LaravelAiTryon\Data\TryOnResult.
Usage Limits and Premium CTA
The package tracks usage in ai_tryon_usages, not the external provider quota. This is intentional because AI providers do not reliably expose package-level free quota state to your Laravel app.
Limits are checked by authenticated user_id, with guest fallback to IP address:
When a limit is exceeded, the endpoint returns JSON with code: limit_exceeded and the configured premium_url so the frontend can show an upgrade CTA.
Queue Setup
Queueing is enabled by default:
For the database queue:
Set ai-tryon.queue.enabled to false for synchronous local testing.
Privacy Notes
The package validates MIME type and max file size, never exposes API keys to the frontend, and uses Laravel CSRF protection on the upload endpoint.
User photos are stored temporarily so queued jobs can process them. By default, uploads are deleted after generation and the stored user-photo path is cleared:
Show shoppers a clear consent and accuracy notice. AI try-on previews may be inaccurate and should not be treated as a guaranteed product fit.
Provider Details
Gemini requests send:
- the configured prompt
- the uploaded shopper photo as inline base64 image data
- the product image as inline base64 image data
generationConfig.responseModalitiesincluding image output
Generated images are saved to the configured Laravel storage disk.
OpenAI and Replicate provider classes are included as configurable starting points. Production Replicate models vary by schema, so adjust providers.replicate.input_keys or pass custom input options from your application if needed.
Routes
The package registers:
POST /ai-tryon/generateGET /ai-tryon/generations/{uuid}
You can change prefix and middleware in config.
Local Development and Testing
The tests use Orchestra Testbench and SQLite in memory.
Packagist Publishing
- Use your real package name in
composer.json, for examplefahimhossain/laravel-ai-tryon. - Keep the namespace consistent with your autoload mapping, for example
FahimHossain\\LaravelAiTryon. - Push the repository to GitHub.
- Create a Packagist package pointing to the GitHub repository.
- Tag releases with SemVer, for example
v1.0.0.
License
MIT.
All versions of laravel-ai-tryon with dependencies
illuminate/bus Version ^10.0|^11.0|^12.0
illuminate/cache Version ^10.0|^11.0|^12.0
illuminate/console Version ^10.0|^11.0|^12.0
illuminate/contracts Version ^10.0|^11.0|^12.0
illuminate/database Version ^10.0|^11.0|^12.0
illuminate/filesystem Version ^10.0|^11.0|^12.0
illuminate/http Version ^10.0|^11.0|^12.0
illuminate/queue Version ^10.0|^11.0|^12.0
illuminate/routing Version ^10.0|^11.0|^12.0
illuminate/support Version ^10.0|^11.0|^12.0
illuminate/validation Version ^10.0|^11.0|^12.0
illuminate/view Version ^10.0|^11.0|^12.0