sharpapi / laravel-ecommerce-product-description
AI Product Description Generator for Laravel powered by SharpAPI.com
Package info
github.com/sharpapi/laravel-ecommerce-product-description
pkg:composer/sharpapi/laravel-ecommerce-product-description
Requires
- php: ^8.1
- ext-json: *
- laravel/framework: ^10.48.29|^11.0|^12.0|^13.0
- sharpapi/php-core: ^1.4.1
Requires (Dev)
- laravel/pint: ^1.0
- orchestra/testbench: ^8.22|^9.0|^10.0|^11.0
- pestphp/pest: ^2.34|^3.0|^4.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
AI Product Description Generator for Laravel
🚀 Leverage AI API to generate detailed product descriptions for E-commerce applications.
Check the details at SharpAPI's E-commerce API page.
Requirements
- PHP >= 8.1
- Laravel >= 10.48.29
Installation
- Install the package via
composer:
composer require sharpapi/laravel-ecommerce-product-description
-
Register at SharpAPI.com to obtain your API key.
-
Set the API key in your
.envfile:
SHARP_API_KEY=your_api_key_here
- [OPTIONAL] Publish the configuration file:
php artisan vendor:publish --tag=sharpapi-ecommerce-product-description
Usage
Inject EcommerceProductDescriptionService (or resolve it from the container). The call is asynchronous:
generateProductDescription()submits the job and returns a status URL.fetchResults($statusUrl)polls until the job finishes and returns aSharpApiJob.- Check
$job->statusbefore reading the result; a failed job does not throw.
fetchResults() can block for up to SHARP_API_JOB_STATUS_POLLING_WAIT seconds, so call it from a queued job, not in a web request.
use SharpAPI\Core\Enums\SharpApiJobStatusEnum; use SharpAPI\EcommerceProductDescription\EcommerceProductDescriptionService; public function handle(EcommerceProductDescriptionService $service): void { $statusUrl = $service->generateProductDescription( 'Razer Blade 16 Gaming Laptop, NVIDIA RTX 4090, Intel i9, 32GB RAM, 2TB SSD', language: 'English', // optional, defaults to 'English' maxLength: 800, // optional voiceTone: 'Professional', // optional context: null, // optional extra instructions ); $job = $service->fetchResults($statusUrl); if ($job->status === SharpApiJobStatusEnum::SUCCESS->value) { $result = json_decode($job->getResultJson(), true); } }
Parameters
productData(string): product name plus as many details as you havelanguage(string|null): output language as a full name, e.g. "English" (default'English')maxQuantity(int|null): sent to the API asmax_quantitymaxLength(int|null): length limit, sent asmax_lengthvoiceTone(string|null): tone of voice, e.g. "Professional"context(string|null): extra instructions for the AI
Optional Configuration
SHARP_API_KEY=your_api_key_here SHARP_API_JOB_STATUS_POLLING_WAIT=180 SHARP_API_JOB_STATUS_USE_POLLING_INTERVAL=false SHARP_API_JOB_STATUS_POLLING_INTERVAL=10 SHARP_API_BASE_URL=https://sharpapi.com/api/v1
AI agents (Laravel Boost)
This package ships a Laravel Boost skill, sharpapi-ecommerce-product-description, that teaches AI coding agents how to call EcommerceProductDescriptionService correctly: submit, then fetchResults() in a queued job, check the job status, and read the result. It loads on demand and adds no always-on guideline. Boost 2 or newer is required.
In the host app:
composer require laravel/boost --dev php artisan boost:install # first time php artisan boost:update --discover # already using Boost
Select sharpapi/laravel-ecommerce-product-description when Boost lists the packages it found.
Changelog
Please see CHANGELOG for a detailed list of changes.
Credits
License
The MIT License (MIT).