PHP code example of laravel-ai / cli

1. Go to this page and download the library: Download laravel-ai/cli 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/ */

    

laravel-ai / cli example snippets

bash
php artisan ai
bash
php artisan ai:ask "What are the best practices for Laravel security?"
bash
php artisan ai:explain storage/logs/laravel.log
bash
php artisan ai:review /path/to/your/file.php
bash
php artisan ai:review app/Models/User.php
bash
php artisan ai:image "A beautiful sunset over mountains"
bash
php artisan ai:ask {prompt}
bash
php artisan ai:explain {file}
bash
php artisan ai:explain storage/logs/laravel.log
bash
php artisan ai:optimize {file}
bash
php artisan ai:optimize app/Models/User.php
bash
php artisan ai:refactor {file}
bash
php artisan ai:refactor app/Http/Controllers/ProductController.php
bash
php artisan ai:document {file}
bash
php artisan ai:document app/Services/PaymentService.php

How would you like to receive the documentation?:
  [0] Display in terminal
  [1] Save to file (DOCUMENTATION_PaymentService.md)
 > 1
bash
php artisan ai:image {prompt} {options}
bash
php artisan ai:image "A serene mountain landscape at sunset"

Select image quality:
  [0] high
  [1] medium
  [2] low
 > 0

Select aspect ratio:
  [0] square
  [1] portrait
  [2] landscape
 > 2

✓ Successfully generated image!
1. /Users/hardik/laravel-php/laravel-ai-cli/IMAGE_2026-02-07_15-30-45_1.png
📋 Metadata saved to: /Users/hardik/laravel-php/laravel-ai-cli/metadata_2026-02-07_15-30-45.json
bash
# Generate 3 images at once
php artisan ai:image "A futuristic city" --count=3 --metadata
bash
php artisan ai:imagemod {image} {modification} {options}
bash
php artisan ai:imagemod image.png "Make it more vibrant and increase contrast"

Select image quality:
  [0] high
  [1] medium
  [2] low
 > 0

Select aspect ratio:
  [0] square
  [1] portrait
  [2] landscape
  [3] keep-original
 > 3

✓ Successfully generated image modification!
1. /Users/hardik/laravel-php/laravel-ai-cli/IMAGE_MOD_2026-02-07_15-31-22_1.png
📋 Metadata saved to: /Users/hardik/laravel-php/laravel-ai-cli/metadata_2026-02-07_15-31-22.json
bash
composer dump-autoload