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\Polyglot\Inference\InferenceCognesy\Polyglot\Embeddings\EmbeddingsCognesy\Instructor\StructuredOutputCognesy\Polyglot\Inference\Contracts\CanCreateInferenceCognesy\Polyglot\Embeddings\Contracts\CanCreateEmbeddingsCognesy\Instructor\Contracts\CanCreateStructuredOutputCognesy\Instructor\Laravel\Testing\StructuredOutputFakeCognesy\Instructor\Laravel\Testing\AgentCtrlFake
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(...)
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/instructor
Config File
Main config file:packages/laravel/resources/config/instructor.php
defaultconnectionsembeddingsextractionhttploggingeventscacheagents