PHP code example of vedanshi-shethia / ai-banner-generator

1. Go to this page and download the library: Download vedanshi-shethia/ai-banner-generator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

vedanshi-shethia / ai-banner-generator example snippets


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'],
    ],

];


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

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

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

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


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

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

ImageStorage::store($base64);

new GeminiDriver($config);

new OpenAIDriver($config);

new NullDriver($config);

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;
    }
}

use Vedanshi\Banner\Factory\BannerDriverFactory;

BannerDriverFactory::extend('my-driver', function ($config) {
    return new MyDriver($config);
});
bash
php artisan vendor:publish --tag=ai-banner-generator
bash
config/ai-banner-generator.php
bash
php artisan storage:link