Skip to content

Commit bfe64f6

Browse files
authored
Update README.md
1 parent 5ed5e9a commit bfe64f6

File tree

1 file changed

+32
-20
lines changed

1 file changed

+32
-20
lines changed

README.md

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,28 @@
66
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/tarantool-php/mapper/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/tarantool-php/mapper/?branch=master)
77
[![Code Coverage](https://scrutinizer-ci.com/g/tarantool-php/mapper/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/tarantool-php/mapper/?branch=master)
88

9-
Install using composer.
10-
```json
11-
{
12-
"require": {
13-
"tarantool/mapper": "^2.7.2"
14-
}
15-
}
9+
- [Installation](#installation)
10+
- [Instantiate mapper](#instantiate-mapper)
11+
- [Logging](#logging)
12+
- [Existing types](#existing-types)
13+
- [Describe entities](#describe-entities)
14+
- [Use migrations](#use-migrations)
15+
- [Use fluent api](#use-fluent-api)
16+
- [Working with the data](#working-with-the-data)
17+
- [Indexes](#indexes)
18+
- [Array properties](#array-properties)
19+
- [Sequence plugin](#sequence-plugin)
20+
- [User-defined classes plugin](#user-defined-classes-plugin)
21+
- [Annotation plugin](#annotation-plugin)
22+
- [Internals](#internals)
23+
24+
## Installation
25+
The recommended way to install the library is through [Composer](http://getcomposer.org):
26+
```
27+
$ composer require tarantool/mapper
1628
```
1729

18-
# Instantiate mapper
30+
## Instantiate mapper
1931
Usually, you manage dependencies in your service provider.
2032
To get started you should instantiate connection, packer, client and mapper itself.
2133
In this example we use PurePacker and StreamConnection. It means you don't need any pecl extensions. To see other implementations please check [client documentation](https://github.com/tarantool-php/client#usage)
@@ -31,7 +43,7 @@ $client = new Client($connection, new PurePacker());
3143
$mapper = new Mapper($client);
3244
```
3345

34-
# Logging
46+
## Logging
3547
By default, client does not logs tarantool requests, you can use mapper\client that supports logging.
3648
```php
3749
use Tarantool\Client\Connection\StreamConnection;
@@ -48,7 +60,7 @@ $result = $client->ping();
4860
$log = $client->getLog();
4961
```
5062

51-
# Existing types
63+
## Existing types
5264
You can start with your current configuration.
5365
Please, note - all instances are mapped to key-value objects.
5466
```php
@@ -66,7 +78,7 @@ echo $guest->type; // user
6678

6779
```
6880

69-
# Describe entities
81+
## Describe entities
7082
To get started you should describe your types and fields using meta object.
7183
```php
7284

@@ -109,7 +121,7 @@ $person->createIndex([
109121
]);
110122
```
111123

112-
# Use migrations
124+
## Use migrations
113125

114126
```php
115127
use Tarantool\Mapper\Mapper;
@@ -133,7 +145,7 @@ $mapper->getBootstrap()->migrate();
133145

134146
```
135147

136-
# Use fluent api
148+
## Use fluent api
137149

138150
```php
139151
use Tarantool\Mapper\Mapper;
@@ -152,7 +164,7 @@ class InitTesterSchema implements Migration
152164

153165
```
154166

155-
# Working with the data
167+
## Working with the data
156168
Now you can store and retreive data from tarantool storage using mapper instance.
157169
```php
158170
// get repository instance
@@ -184,7 +196,7 @@ $helloWorld = $mapper->find('post', 3);
184196
$helloWorld->title = "Hello World!";
185197
$mapper->save($helloWorld);
186198
```
187-
# Indexes
199+
## Indexes
188200
```php
189201
$note = $mapper->getSchema()->createSpace('note');
190202
$note->addProperty('slug', 'str');
@@ -223,7 +235,7 @@ $mapper->find('person', ['client' => 2]);
223235
$mapper->find('person', ['client' => 2, 'sector' => 27]);
224236
```
225237

226-
# Array properties
238+
## Array properties
227239
You can store arrays as property without any serialization to string.
228240
```php
229241
$pattern = $mapper->getSchema()->createSpace('shift_pattern');
@@ -250,7 +262,7 @@ $mapper->create('shift_pattern', [
250262
$mapper->get('shift_pattern', 1)->pattern[5]; // read element with index 5 from pattern array
251263
```
252264

253-
# Sequence plugin
265+
## Sequence plugin
254266
If you want you can use sequence plugin that generates next value based on sequence space.
255267
Or you can implement id generator using any other source, for example with raft protocol.
256268
```php
@@ -270,7 +282,7 @@ $entity = $mapper->create('post', [
270282
echo $entity->id; // will be set when you create an instance
271283
```
272284

273-
# User-defined classes plugin
285+
## User-defined classes plugin
274286
If you want you can specify classes to use for repository and entity instances.
275287
Entity and repository class implementation are ommited, but you should just extend base classes.
276288
```php
@@ -287,7 +299,7 @@ get_class($nekufa); // Application\Models\Person;
287299
$mapper->getSchema()->getSpace('person')->getRepository(); // will be instance of Application\Repositories\Person
288300
```
289301

290-
# Annotation plugin
302+
## Annotation plugin
291303
You can describe your entities using dobclock. Mapper will create space, format and indexes for you.
292304

293305
```php
@@ -375,7 +387,7 @@ $post = $mapper->create('post', [
375387

376388
```
377389

378-
# Internals
390+
## Internals
379391
Mapper uses IdentityMap and query caching
380392
```php
381393
$dmitry = $mapper->getRepository('person')->findOne(['name' => 'Dmitry']); // person with id 1

0 commit comments

Comments
 (0)