> For the complete documentation index, see [llms.txt](https://wirebox.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wirebox.ortusbooks.com/advanced-topics/providers/virtual-provider-injection-dsl.md).

# Virtual Provider Injection DSL

You can inject automatic object providers by using the provider injection DSL namespace. This will inject a WireBox provider class (`wirebox.system.ioc.Provider`) that follows our [Provider pattern](http://en.wikipedia.org/wiki/Provider_model) with one method on it: `get()` that will provide you with the requested mapped object.

The difference between custom providers here is that WireBox will create a virtual provider object for you dynamically at runtime, configure it to retrieve a specific type of mapping and then use that for you. The **provider** namespace will take everything after it and evaluate it as either a named mapping or a full injection DSL string.

For example, `inject="provider:MyService"` will inject a provider of `MyService` objects, so it will look for a `MyService` ID in the binder. However, you can also get mega funky and do this: `inject="provider:logbox:logger:{this}"` and WireBox will create a provider of `logbox:logger:{this}`.

> **Caution** Remember that the value of the provider can be a simple ID or a full injection DSL.

```javascript
// use the provider DSL namespace on a property
property name="searchCriteria" inject="provider:requestCriteria";

// use the provider DSL namespace on a constructor argument
function init(coolObjectProvider inject="provider:HardToConstructObject"){
    variables.coolObjectProvider = arguments.coolObjectProvider;
    return this;
}

// To use it
searchCriteria.get().getCriteria();
coolObjectProvider.get().executeSomeMethod();
```

\
That's it! You basically use the `provider:{mapping}` injection DSL to tell a property, setter or argument that you want a provider object instead of the real deal. This will allow you to delay construction of such an object or avoid the nasty pitfall of scope widening injection.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://wirebox.ortusbooks.com/advanced-topics/providers/virtual-provider-injection-dsl.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
