The philosophy behind Instructor was originally formulated by Jason Liu, creator of the Python version, and adapted for this PHP port.
“Simplicity is a great virtue, but it requires hard work to achieve it and education to appreciate it. And to make matters worse: complexity sells better.” — Edsger Dijkstra
Simplicity
Most users only need to learnStructuredOutput and a response model class to get started.
There is no new prompting language, no framework-specific base class to extend, and no hidden
abstractions between you and the LLM.
Transparency
Instructor writes very few prompts on your behalf, and the ones it does write are visible and configurable. The library does not try to hide what it sends to the model — you stay in control of the conversation.Flexibility
If you already have code that calls an LLM provider directly, adopting Instructor is incremental. Add aresponseModel to your existing call and use get() to receive a typed result. Any plain
PHP class works as a response model — no base class or interface is required.
The Zen of Instructor
Maintain the flexibility and power of PHP classes without unnecessary constraints.- Define a data schema:
class UserProfile { ... } - Add validators and methods on that schema.
- Encapsulate LLM logic in a function:
function extract($text): UserProfile - Write typed computations against the result, or call methods on the object directly.
Our Goals
The goal of the library — and its documentation — is to help you be a better PHP developer and, as a result, a better AI engineer.- The library is a result of a desire for simplicity.
- It should help maintain simplicity in your codebase.
- It will not try to write prompts for you.
- It will not create indirections or abstractions that make debugging harder.