Prerequisites
- PHP 8.2 or higher
- Composer
- An API key from any supported LLM provider
Installation
Configuration
Create a.env file in your project root with your API key:
Your First Extraction
Step 1: Define Your Data Structure
Create a PHP class that represents the data you want to extract:Step 2: Extract Data
Use Instructor to extract structured data from text:Step 3: Add Validation (Optional)
Use Symfony Validator attributes for automatic validation:Using Different Providers
Switch providers with a single method call:Processing Images
Extract data from images using vision-capable models:Streaming Responses
Get partial results as they arrive:Next Steps
You now have the basics. Here’s where to go next:| Goal | Resource |
|---|---|
| Learn core concepts | Why Instructor |
| See practical examples | Cookbook |
| Explore all features | Features Overview |
| Configure providers | LLM Providers |
| Advanced validation | Validation Guide |
Common Patterns
Extract Multiple Items
Add Context with System Messages
Set Max Retries
Need help? Check out the Cookbook for 60+ working examples, or open an issue on GitHub.