Download the PHP package laravel-ai/cli without Composer
On this page you can find all versions of the php package laravel-ai/cli. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download laravel-ai/cli
More information about laravel-ai/cli
Files in laravel-ai/cli
Package cli
Short Description AI-powered CLI tools for Laravel using Laravel AI SDK
License MIT
Informations about the package cli
Laravel AI CLI
AI-powered CLI tools for Laravel using the Laravel AI SDK. This package provides intelligent commands for asking questions, explaining errors, and reviewing code directly from your terminal.
Features
- Help Command (
ai) - Display comprehensive help information and all available commands - Ask Agent (
ai:ask) - Ask AI a question about your code or any topic - Explain Agent (
ai:explain) - Understand application errors and log files - Review Agent (
ai:review) - Get code reviews from an AI senior engineer - Optimize Agent (
ai:optimize) - Optimize code for performance and efficiency - Refactor Agent (
ai:refactor) - Refactor code for better quality and maintainability - Document Agent (
ai:document) - Generate comprehensive markdown documentation (display in terminal or save to file) - Image Generator (
ai:image) - Generate images from text descriptions with interactive quality and aspect ratio selection - Image Modifier (
ai:imagemod) - Modify and enhance existing images with AI-powered transformation
Requirements
- PHP ^8.2
- Laravel ^12.0
- Laravel AI SDK ^0.1
Installation
1. Add the Package to Your Laravel Project
The package will be automatically discovered by Laravel via service provider auto-discovery.
2. Configure Your AI Provider
Currently Supported: OpenAI
Configure your OpenAI API key in your .env file:
Coming Soon: More providers including Anthropic Claude, Google Gemini, and Cohere will be integrated in upcoming releases.
Usage
Get Help
Display comprehensive help information and all available commands:
This will show package information, version details, and usage examples for all available commands.
Ask a Question
Ask the AI assistant any question:
Explain an Error
Get a clear explanation of error messages or log files:
Example:
Review Code
Get feedback on your code from an AI senior engineer:
Example:
Generate Images
Generate AI images from text descriptions:
The command will prompt you to select:
- Quality: high, medium, or low
- Aspect Ratio: square, portrait, or landscape
- Count: 1-4 images to generate
Options:
Modify Images
Modify and enhance existing images:
The command will prompt you to select:
- Quality: high, medium, or low
- Aspect Ratio: square, portrait, landscape, or keep-original
- Count: 1-4 variations to generate
Options:
Command Details
ai:ask
Arguments:
prompt- Your question for the AI
Example:
ai:explain
Arguments:
file- Path to the error or log file to explain
Example:
ai:optimize
Arguments:
file- Path to the source code file to optimize
Example:
ai:refactor
Arguments:
file- Path to the source code file to refactor
Example:
ai:document
Generates comprehensive markdown documentation. The command will prompt you to choose how to receive the documentation:
Arguments:
file- Path to the source code file to document
Output Options:
- Display in Terminal - View formatted markdown directly in your terminal
- Save to File - Save as
DOCUMENTATION_{filename}.mdin project root
Example:
The generated documentation includes:
- Detailed overview and purpose
- PHPDoc style comments
- Parameter documentation
- Usage examples with code blocks
- Important notes and edge cases
- Related files references
ai:image
Generates AI-powered images from text descriptions.
Arguments:
prompt- Description or prompt for the image to generate
Options:
--output=PATH- Save to a specific file path--dir=PATH- Save to a specific directory (defaults to project root)--count=N- Generate 1-4 images at once (default: 1)--timeout=N- HTTP timeout in seconds (default: 120)--metadata- Save generation metadata to JSON file
Example:
Batch Generation:
ai:imagemod
Modifies and enhances existing images using AI.
Arguments:
image- Path to the image file to modifymodification- Description of modifications to apply
Options:
--output=PATH- Save to a specific file path--dir=PATH- Save to a specific directory (defaults to project root)--count=N- Generate 1-4 variations (default: 1)--timeout=N- HTTP timeout in seconds (default: 120)--metadata- Save modification metadata to JSON file
Supported Image Formats:
- JPEG (.jpg, .jpeg)
- PNG (.png)
- GIF (.gif)
- WebP (.webp)
- SVG (.svg)
Example:
Multiple Variations:
Package Structure
How It Works
- Service Provider - Auto-loads commands on Laravel startup
- Commands - Handle CLI input and file reading
- Agents - Implement the AI logic with specific instructions for each task
- Laravel AI SDK - Handles communication with the AI provider
Each agent uses the Promptable trait and implements the Agent interface, providing specific instructions to the AI for better results.
Configuration
The package respects your Laravel AI configuration. You can customize behavior by:
- Setting environment variables for your AI provider
- Modifying agent instructions in the respective Agent classes
Troubleshooting
"File not found" Error
Ensure the file path is correct and relative to your Laravel project root:
"Undefined type" IDE Errors
Run the following to regenerate autoloader files:
AI Response is Empty
- Verify your API key is set in
.env - Check your API quota/credits
- Ensure the file exists and is readable
License
MIT License. See LICENSE file for details.
Support
For issues or feature requests, please open an issue on the repository.