Configuration

Configuration

The configuration file for Articulate is located at config/articulate.php and contains three options.

This is what the default file looks like;


return [

    'mappers' => [

    ],

    'attributes' => [
        'bool'      => \Sprocketbox\Articulate\Attributes\BoolAttribute::class,
        'entity'    => \Sprocketbox\Articulate\Attributes\EntityAttribute::class,
        'int'       => \Sprocketbox\Articulate\Attributes\IntAttribute::class,
        'json'      => \Sprocketbox\Articulate\Attributes\JsonAttribute::class,
        'string'    => \Sprocketbox\Articulate\Attributes\StringAttribute::class,
        'timestamp' => \Sprocketbox\Articulate\Attributes\TimestampAttribute::class,
        'float'     => \Sprocketbox\Articulate\Attributes\FloatAttribute::class,
        'text'      => \Sprocketbox\Articulate\Attributes\TextAttribute::class,
        'array'     => \Sprocketbox\Articulate\Attributes\ArrayAttribute::class,
        'uuid'      => \Sprocketbox\Articulate\Attributes\UuidAttribute::class,
        //'object_id'   => \Sprocketbox\Articulate\Attributes\MongoDB\ObjectIdColumn::class,
        //'subdocument' => \Sprocketbox\Articulate\Attributes\MongoDB\SubdocumentColumn::class,
        //'utc'         => \Sprocketbox\Articulate\Attributes\MongoDB\UtcColumn::class,
    ],

    'sources' => [
        //\Sprocketbox\Articulate\Sources\Illuminate\Source::class,
    ]

];

Registering Mappers

Your entity mappers should be registered in the configuration file. To register them, just list the class namespaces in the mappers array.

An example of this is as follows;

'mappers' => [
    \App\Mappers\UserMapper::class,
    \App\Mappers\PostMapper::class,
    \App\Mappers\CategoryMapper::class,
    \App\Mappers\CommentMapper::class,
],

You can read more about mappers and mappings here.

Registering Attribute Types

All of the attribute types used inside mappers are registered using the attributes configuration option. All of the default types are registered here with some optional types for those of you using MongoDB.

The array key used here will be converted to studlyCase and used as a dynamic method on the mapping, so that you can do things like the following;

$mapping->int('id')->setImmutable();
$mapping->string('name');
$mapping->string('email');
$mapping->string('password');
$mapping->bool('active');
$mapping->int('status');
$mapping->timestamps();

Most of the time you'll find yourself not having to worry about this, but if you have added a custom attribute type, you'd append it to this list.

You can read more about attributes here.

Registering Sources

Each source (Illuminate, Respite, etc) will come with a source class. This works similarly to Laravel service providers, setting up all the basics of what is needed to use that data-source. To register a source, simply add it to the sources array in the configuration.

Below is an example using the Illuminate source;

'sources' => [
    \Sprocketbox\Articulate\Sources\Illuminate\Source::class,
],