Sources

Introduction

Source adapters helps you query any source of data you might encounter in the wild.

Defining Sources

Specify source information in your stream configuration.

If no source is specified, the below defaults will be assumed.

// streams/{handle}.json
{
    "config": {
        "source": {
            "format": "json",
            "type": "filebase",
            "path": "streams/data/{handle}"
        }
    }
}

Available Sources

The following sources are available with the Streams platform by default.

Self

You can define data within on your stream configuration file.

// streams/contacts.json
{
    "config": {
        "source": {
            "type": "self"
        }
    },
    "data": {
        "john": {
            "name": "John Doe"
        },
        "jane": {
            "name": "Jane Doe"
        }
    }
}

Filebase

The flat file database powered by the fantastic Filebase package is the default source.

// streams/contacts.json
{
    "config": {
        "source": {
            "format": "json",
            "type": "filebase",
            "path": "streams/data/contacts"
        }
    }
}

JSON Format

// streams/data/contacts/ryan.json
{
    "name": "Ryan",
    "email": "[email protected]"
}

YAML Format

@verbatim

// streams/data/contacts/ryan.yaml

---

name: "Ryan"
email: "[email protected]"

---

The body is built in: {{ $entry->name }}

@endverbatim

MD Format

@verbatim

// streams/data/contacts/ryan.md

---

name: "Ryan"
email: "[email protected]"

---

The body is built in: {{ $entry->name }}

@endverbatim

TPL Format

@verbatim

// streams/data/contacts/ryan.tpl

---

name: "Ryan"
email: "[email protected]"

---

The body is built in: {{ $entry->name }}

@endverbatim

Eloquent Model

The eloquent model source uses Laravel models to query and can return stream-enhanced Eloquent models.

// streams/contacts.json
{
    "config": {
        "source": {
            "type": "eloquent",
            "model": "App\\Contact\\ContactModel"
        }
    }
}

Laravel Database

The Laravel database source uses generic Laravel database tables to query and return stream entries.

// streams/contacts.json
{
    "config": {
        "source": {
            "type": "database",
            "table": "contacts",
            "connection": "default"
        }
    }
}

Extending

You can create and register a custom source adapter for any source of information you might encounter.

Custom Sources

@todo Talk about developing custom source adapters.