Skip to content

Commit

Permalink
Add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
bakura10 committed Apr 4, 2014
1 parent 4ab856a commit 57f63a7
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 5 deletions.
16 changes: 16 additions & 0 deletions docs/02. Quick Start.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
In this minimal example, we are going to create an API that allow to create, delete and retrieve one or many users
using ZfrRest.

## Configuring ZfrRest

Before using ZfrRest, we need to add a few lines of config. In your `global.config.php` file (for instance), add the
following piece of config:

```php
'zfr_rest' => [
'object_manager' => 'doctrine.entitymanager.orm_default',
'drivers' => [['class' => 'ZfrRest\Resource\Metadata\Driver\AnnotationDriver']],
'cache' => ['adapter' => 'memory']
]
```

Those are sane defaults if you are using Doctrine ORM. This also indicates to ZfrRest to use the AnnotationDriver,
so that it can parses your annotations correctly.

## Creating your entity

The first thing to do is to create your entity. Let's keep it simple:
Expand Down
15 changes: 15 additions & 0 deletions docs/07. Cookbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,21 @@ class CustomUserHydrator extends \Zend\Stdlib\Hydrator\ClassMethods
You finally just need to add this custom hydrator to the hydrator plugin manager, and writing the corresponding
factory.

## Tuning ZfrRest for production

For maximum performance, here are a few best practices:

### Using APC cache for annotation parsing

By default, ZfrRest will parse your annotations at each requests. This can be very slow. In your config file,
change the cache option to use something like APC:

```php
'zfr_rest' => [
'cache' => ['adapter' => 'apc']
]
```

### Navigation

* Continue to [the **Mapping reference**](/docs/08. Mapping reference.md)
Expand Down
12 changes: 7 additions & 5 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ If you are looking for some information that is not listed in the documentation,
4. [Current limitations](/docs/01. Introduction.md#current-limitations)

2. [Quick Start](/docs/02. Quick Start.md)
1. [Creating your entity](/docs/02. Quick Start.md#creating-your-entity)
2. [Adding ZfrRest mapping](/docs/02. Quick Start.md#adding-zfrrest-mapping)
3. [Adding a route](/docs/02. Quick Start.md#adding-a-route)
4. [Adding a controller](/docs/02. Quick Start.md#adding-controllers)
5. [Associations](/docs/02. Quick Start.md#associations)
1. [Configuring ZfrRest](/docs/02. Quick Start.md#configuring-zfrrest)
2. [Creating your entity](/docs/02. Quick Start.md#creating-your-entity)
3. [Adding ZfrRest mapping](/docs/02. Quick Start.md#adding-zfrrest-mapping)
4. [Adding a route](/docs/02. Quick Start.md#adding-a-route)
5. [Adding a controller](/docs/02. Quick Start.md#adding-controllers)
6. [Associations](/docs/02. Quick Start.md#associations)

3. [Using HTTP exceptions for reporting errors](/docs/03. Using HTTP exceptions for reporting errors.md)
1. [Built-in exceptions](/docs/03. Using HTTP exceptions for reporting errors.md#built-in-exceptions)
Expand All @@ -42,6 +43,7 @@ If you are looking for some information that is not listed in the documentation,
4. [How to specify a custom input filter?](/docs/07. Cookbook.md)
5. [How to filter a collection using query params?](/docs/07. Cookbook.md)
6. [How to serialize custom data that do not belong to the entity?](/docs/07. Cookbook.md)
7. [Tuning ZfrRest for production](/docs/07. Cookbook.md)

8. [Mapping reference](/docs/08. Mapping reference.md)
1. [Annotations](/docs/08. Mapping reference.md)

0 comments on commit 57f63a7

Please sign in to comment.