Laravel Package Cheatsheet
Code-verified reference forpackages/laravel.
Package Wiring
Auto-discovered provider:Cognesy\Instructor\Laravel\InstructorServiceProvider
StructuredOutput->Cognesy\Instructor\Laravel\Facades\StructuredOutputInference->Cognesy\Instructor\Laravel\Facades\InferenceEmbeddings->Cognesy\Instructor\Laravel\Facades\EmbeddingsAgentCtrl->Cognesy\Instructor\Laravel\Facades\AgentCtrl
Service Container Bindings
Provided byInstructorServiceProvider::provides():
Cognesy\Events\Contracts\CanHandleEventsCognesy\Config\Contracts\CanProvideConfigCognesy\Http\HttpClientCognesy\Http\Contracts\CanSendHttpRequestsCognesy\Agents\Template\AgentDefinitionRegistryCognesy\Polyglot\Inference\InferenceCognesy\Polyglot\Embeddings\EmbeddingsCognesy\Instructor\StructuredOutputCognesy\Polyglot\Inference\Contracts\CanCreateInferenceCognesy\Polyglot\Embeddings\Contracts\CanCreateEmbeddingsCognesy\Instructor\Contracts\CanCreateStructuredOutputCognesy\Agents\Template\Contracts\CanManageAgentDefinitionsCognesy\Agents\Tool\ToolRegistryCognesy\Agents\Tool\Contracts\CanManageToolsCognesy\Agents\Capability\AgentCapabilityRegistryCognesy\Agents\Capability\CanManageAgentCapabilitiesCognesy\Agents\Capability\StructuredOutput\SchemaRegistryCognesy\Agents\Capability\StructuredOutput\CanManageSchemasCognesy\Agents\Session\Store\InMemorySessionStoreCognesy\Instructor\Laravel\Agents\Session\DatabaseSessionStoreCognesy\Agents\Session\Contracts\CanStoreSessionsCognesy\Agents\Session\SessionRepositoryCognesy\Agents\Session\Contracts\CanManageAgentSessionsCognesy\Agents\Template\Factory\DefinitionLoopFactoryCognesy\Agents\Template\Contracts\CanInstantiateAgentLoopCognesy\Agents\Session\SessionRuntimeCognesy\Agents\Broadcasting\BroadcastConfigCognesy\Instructor\Laravel\Agents\Broadcasting\NullAgentEventTransportCognesy\Instructor\Laravel\Agents\Broadcasting\LaravelAgentEventTransportCognesy\Agents\Broadcasting\CanBroadcastAgentEventsCognesy\Instructor\Laravel\Agents\Broadcasting\LaravelAgentBroadcastingCognesy\Telemetry\Application\Registry\TraceRegistryCognesy\Telemetry\Application\TelemetryCognesy\Telemetry\Domain\Contract\CanExportObservationsCognesy\Telemetry\Domain\Contract\CanFlushTelemetryCognesy\Telemetry\Domain\Contract\CanShutdownTelemetryCognesy\Telemetry\Application\Projector\CanProjectTelemetryCognesy\Telemetry\Application\Projector\RuntimeEventBridgeCognesy\Instructor\Laravel\Testing\StructuredOutputFakeCognesy\Instructor\Laravel\Testing\AgentCtrlFakeCognesy\Instructor\Laravel\Testing\NativeAgentTesting
Facades
StructuredOutput facade:
StructuredOutput::connection(string $name): Cognesy\Instructor\StructuredOutput|StructuredOutputFakeStructuredOutput::fromConfig(LLMConfig $config): Cognesy\Instructor\StructuredOutput|StructuredOutputFakeStructuredOutput::fake(array $responses = []): StructuredOutputFake- forwards to
Cognesy\Instructor\StructuredOutput(for example:with(...)->get())
Inference facade:
Inference::connection(string $name): Cognesy\Polyglot\Inference\Inference|InferenceFakeInference::fromConfig(LLMConfig $config): Cognesy\Polyglot\Inference\Inference|InferenceFakeInference::fake(array $responses = []): InferenceFake- forwards to
Cognesy\Polyglot\Inference\Inference(for example:with(...)->get())
Embeddings facade:
Embeddings::connection(string $name): Cognesy\Polyglot\Embeddings\Embeddings|EmbeddingsFakeEmbeddings::fromConfig(EmbeddingsConfig $config): Cognesy\Polyglot\Embeddings\Embeddings|EmbeddingsFakeEmbeddings::fake(array $responses = []): EmbeddingsFake- forwards to
Cognesy\Polyglot\Embeddings\Embeddings(for example:withInputs(...)->first())
AgentCtrl facade:
AgentCtrl::fake(array $responses = []): AgentCtrlFakeAgentCtrl::claudeCode(): ClaudeCodeBridgeBuilder|AgentCtrlFakeAgentCtrl::codex(): CodexBridgeBuilder|AgentCtrlFakeAgentCtrl::openCode(): OpenCodeBridgeBuilder|AgentCtrlFakeAgentCtrl::make(AgentType $type): ClaudeCodeBridgeBuilder|CodexBridgeBuilder|OpenCodeBridgeBuilder|AgentCtrlFake
Testing Fakes
StructuredOutputFake:
- setup:
respondWith(string $class, mixed $response),respondWithSequence(string $class, array $responses) - assertions:
assertExtracted,assertExtractedTimes,assertNothingExtracted,assertExtractedWith,assertUsedConnection,assertUsedModel - inspection:
recorded(): array
InferenceFake:
- setup:
respondWith(string $pattern, string|array $response),respondWithSequence(array $responses) - assertions:
assertCalled,assertCalledTimes,assertNotCalled,assertCalledWith,assertUsedConnection,assertUsedModel,assertCalledWithTools - inspection:
recorded(): array
EmbeddingsFake:
- setup:
respondWith(string $pattern, array $embedding),withDimensions(int $dimensions) - assertions:
assertCalled,assertCalledTimes,assertNotCalled,assertCalledWith,assertUsedConnection,assertUsedModel - results:
get(): object,first(): array,all(): array - inspection:
recorded(): array
AgentCtrlFake:
- builders:
claudeCode(),codex(),openCode(),make(AgentType $type) - builder config:
withModel(string $model),withTimeout(int $seconds),inDirectory(string $path),withSandboxDriver(mixed $driver),withMaxRetries(int $retries) - builder callbacks:
onText(callable $handler),onToolUse(callable $handler),onComplete(callable $handler) - execution:
execute(string $prompt): AgentResponse,executeStreaming(string $prompt): AgentResponse - assertions:
assertExecuted,assertNotExecuted,assertExecutedTimes,assertExecutedWith,assertAgentType,assertUsedClaudeCode,assertUsedCodex,assertUsedOpenCode,assertStreaming - inspection:
getExecutions(): array,reset(): void - static helpers:
AgentCtrlFake::response(...),AgentCtrlFake::toolCall(...)
NativeAgentTesting:
fakeDriver(?FakeAgentDriver $driver = null, string $capabilityName = 'use_test_driver'): FakeAgentDriverfakeSessions(?InMemorySessionStore $store = null): InMemorySessionStorefakeBroadcasts(?RecordingAgentEventTransport $transport = null): RecordingAgentEventTransportcaptureTelemetry(?RecordingTelemetryExporter $exporter = null): RecordingTelemetryExporter
Artisan Commands
instructor:install {--force}instructor:test {--connection=} {--inference}make:response-model {name} {--collection} {--nested} {--description=} {--force}
Publish Tags
FromInstructorServiceProvider:
instructor-config-> publishesconfig/instructor.phpinstructor-stubs-> publishesresources/stubstostubs/instructorinstructor-migrations-> publishes native-agent session migration(s)
Logging
Logging is configured throughconfig/instructor.php and applied from InstructorServiceProvider.
The pipeline writes to a Laravel log channel and enriches records with request context.
Relevant env vars:
INSTRUCTOR_LOGGING_ENABLED(default:true)INSTRUCTOR_LOGGING_PRESET(default|production|custom)INSTRUCTOR_LOG_CHANNEL— Laravel log channel name (default:stack)INSTRUCTOR_LOG_LEVEL— minimum PSR log level (default:warning)
default— request-enriched development logging with agent-aware templatesproduction— warning-level logging with streaming/partial noise excludedcustom— useslogging.channel,logging.level,logging.exclude_events,logging.include_events, andlogging.templates
Config File
Main config file:packages/laravel/resources/config/instructor.php
defaultconnectionsembeddingsextractionhttploggingeventscacheagentsagent_ctrltelemetry
agentsreserves the nativeCognesy\Agentsruntime surface for Laravel container, persistence, and observability integration.agent_ctrlconfigures CLI code agents used by theAgentCtrlfacade.telemetryconfigures Laravel-side telemetry export and runtime projector wiring.