Skip to content

Commit

Permalink
Add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Korbeil committed Nov 6, 2023
1 parent a2110e9 commit bc8f6fd
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 0 deletions.
Empty file added docs/.nojekyll
Empty file.
48 changes: 48 additions & 0 deletions docs/homepage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Welcome 👋

Welcome to the AutoMapper documentation, this library solves a simple problem: removing all the code you need to
map one object to another. A boring code to write and often replaced by less-performant alternatives like the Symfony's
Serializer.

AutoMapper uses a convention-based matching algorithm to match up source to destination values. AutoMapper is geared
towards model projection scenarios to flatten complex object models to DTOs and other simple objects, whose design is
better suited for serialization, communication, messaging, or simply an anti-corruption layer between the domain and
application layer.

## Quick start 🚀

### What is the AutoMapper ? 🤔

The AutoMapper is an object-object mapper. Object-object mapping works by transforming an input object of one type into
an output object of a different type. What makes AutoMapper interesting is that it provides some interesting conventions
to take the dirty work out of figuring out how to map type A to type B and it has a strong aim on performance by
generating the mappers whenever you require it. As long as type B follows AutoMapper’s established convention, almost
zero configuration is needed to map two types.

### Why should I use it ? 🙋

Mapping code is boring. And in PHP, you often replace that by using Symfony's Serializer because you don't want to do
it by hand. We were doing the same but performance made it not possible anymore. The AutoMapper replaces the Serializer
to do the same output by generating PHP code so it's like your wrote the mappers yourself.

The real question may be “why use object-object mapping?” Mapping can occur in many places in an application, but
mostly in the boundaries between layers, such as between the UI/Domain layers, or Service/Domain layers. Concerns of
one layer often conflict with concerns in another, so object-object mapping leads to segregated models, where concerns
for each layer can affect only types in that layer.

### Installation 📦

```shell
$ composer require jolicode/automapper
```

### How to use it ? 🕹️

First, you need both a source and destination type to work with. The destination type’s design can be influenced by the
layer in which it lives, but the AutoMapper works best as long as the names of the members match up to the source
type’s members. If you have a source member called "firstName", this will automatically be mapped to a destination
member with the name "firstName".

The AutoMapper will accept any array of object as source type and any class-string, array or object as target type.

TODO
31 changes: 31 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="description" content="Description">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify@4/lib/themes/dark.css">
</head>
<body>
<div id="app"></div>
<script>
window.$docsify = {
name: 'AutoMapper',
repo: 'jolicode/automapper',
auto2top: true,
themeColor: '#f7d325',
homepage: 'homepage.md',
loadSidebar: 'navigation.md',
alias: {
'/docs/(.*)': '/$1.md'
}
}
</script>
<!-- Docsify v4 -->
<script src="//cdn.jsdelivr.net/npm/docsify@4"></script>
<script src="//cdn.jsdelivr.net/npm/prismjs@1/components/prism-bash.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/prismjs@1/components/prism-php.min.js"></script>
</body>
</html>
2 changes: 2 additions & 0 deletions docs/navigation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- [Quick start](/)
- Coucou

0 comments on commit bc8f6fd

Please sign in to comment.