Skip to main content

Release Notes v1.14.0

New Package: instructor-laravel

Laravel Integration Package (packages/laravel/) A dedicated package providing first-class Laravel integration for Instructor PHP:

Facades

Four main facades for interacting with LLMs and code agents:
  • StructuredOutput:: - Extract structured data from text with validation and retries
  • Inference:: - Raw LLM inference without structured output constraints
  • Embeddings:: - Generate text embeddings for vector operations
  • AgentCtrl:: - Invoke CLI-based code agents (Claude Code, Codex, OpenCode)

Testing Fakes

Laravel-style testing doubles with ::fake() pattern:
Available fakes:
  • StructuredOutput::fake() - Mock structured output responses
  • Inference::fake() - Mock inference responses with pattern matching
  • Embeddings::fake() - Mock embedding vectors
  • AgentCtrl::fake() - Mock code agent executions

Laravel HTTP Client Integration

Uses Laravel’s Http:: client internally, enabling:
  • Full compatibility with Http::fake() in tests
  • Request/response logging through Laravel’s HTTP middleware
  • Automatic retry handling via Laravel’s HTTP client features

Event Bridge

Instructor events are automatically dispatched to Laravel’s event system:

Artisan Commands

  • php artisan instructor:install - Publish configuration and setup
  • php artisan instructor:test - Test your API configuration
  • php artisan make:response-model - Generate response model classes

Configuration

Laravel-style configuration with environment variables:

New Feature: AgentCtrl Facade

Unified API for Controlling Agents The AgentCtrl facade provides access to CLI-based code agents that can execute code, modify files, and perform complex tasks:

Supported Agents

Usage

Streaming Support

Session Management

Testing

Sandbox Drivers

Control agent execution isolation:

Installation

Add to your .env:
The package auto-discovers and registers itself with Laravel.

Migration Notes

For Existing Instructor Users

The Laravel package is additive - no changes required to existing code. You can:
  1. Continue using Instructor directly via dependency injection
  2. Adopt facades gradually where convenient
  3. Use ::fake() pattern for new tests
  1. Install the package
  2. Replace Http::fake() based tests with StructuredOutput::fake()
  3. Adopt facades in new code for cleaner syntax
  4. Migrate existing DI usage to facades where appropriate

Key Benefits

  • Laravel Integration: Facades, fakes, and configuration follow Laravel conventions
  • Testing: ::fake() pattern with comprehensive assertions
  • Zero Configuration: Works out of the box with sensible defaults
  • Event Integration: Full visibility into Instructor operations via Laravel events
  • Code Agents: Access powerful CLI agents directly from your Laravel application