docs/03. Providers.md
# Providers
You can create containers using different providers. The default provider is the [ArrayProvider](../src/SpotOnLive/Navigation/Navigation/Providers/ArrayProvider.php).
All the default providers is located in [`src/SpotOnLive/Navigation/Providers`](../src/SpotOnLive/Navigation/Navigation/Providers).
## ArrayProvider
`SpotOnLive\Navigation\Navigation\Providers\ArrayProvider`
The array provider is used as default. For usage see [Containers](02. Containers.md)
## JsonProvider
`SpotOnLive\Navigation\Navigation\Providers\JsonProvider`
Create a navigation container from a json file. Example of usage:
*config/navigation.php*
```php
'container.name' => [
'provider' => SpotOnLive\Navigation\Navigation\Providers\JsonProvider::class,
'provider_options => [
'path' => storage_path('routes.json')
],
],
```
*routes.json*
```json
{
"pages": [
{
"options": {
"label": "Home",
"route": "home"
},
"a_attributes": {
"class": "link"
}
},
{
"options": {
"label": "Sign in",
"url": "auth/login"
},
"a_attributes": {
"class": "link auth-link"
}
}
]
}
```
## YamlProvider
`SpotOnLive\Navigation\Navigation\Providers\YamlProvider`
Create a navigation container from a yaml file. Example of usage:
*config/navigation.php*
```php
'container.name' => [
'provider' => SpotOnLive\Navigation\Navigation\Providers\YamlProvider::class,
'provider_options => [
'path' => storage_path('routes.yaml')
],
],
```
*routes.yaml*
```yaml
---
pages:
- options:
label: Home
route: home
a_attributes:
class: link
- options:
label: Sign in
url: auth/login
a_attributes:
class: link auth-link
```
* Go back to [**Containers**](02. Containers.md)
* Continue to [**Render**](04. Render.md)