-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.md.php
58 lines (45 loc) · 1.47 KB
/
index.md.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
use Maslosoft\Ilmatar\Widgets\Form\ActiveForm;
use Maslosoft\Ilmatar\Components\Controller;
?>
<?php
/* @var $this Controller */
/* @var $form ActiveForm */
?>
<template>docs</template>
<title>Documentation</title>
# Documentation
Mangan goal is to allow storing PHP objects in MongoDB. These can be
composed in more complex structures, be either embedding, referencing or relations.
It is generally ready to use out of a package. However at least some minimal
configuration is required, for instance database name.
### Installation
Use composer to install mangan:
```
composer require maslosoft/mangan
```
### Configuration
It is recommended to use [EmbeDi](/embedi/) to [configure Mangan](configuration/). This allow
separation configuration from actual usage. Minimum configuration required
is database name, using property `dbName`. Default configuration ID is `mongodb`.
*Use statements omitted*
```
$config = [
'mongodb' => [
'class' => Mangan::class,
// Database name
'dbName' => 'quick-start',
]
];
EmbeDi::fly()->addAdapter(new ArrayAdapter($config));
```
Now, assuming that we have some models ready, Mangan is ready to do it's duty.
When using built-in base documents classes, [active document][ad] (derived from active record)
pattern can be used, for instance:
```
$plant = new Plant;
$plant->name = 'Grass';
$plant->save();
```
Check [this repository for working example of Mangan](https://github.com/MaslosoftGuides/mangan.quick-start)
[ad]: define-model/active-document/