Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a Cookbook #514

Merged
merged 12 commits into from
Sep 21, 2019
Merged

Adding a Cookbook #514

merged 12 commits into from
Sep 21, 2019

Conversation

mamazu
Copy link
Member

@mamazu mamazu commented Aug 13, 2019

Well Shop Api got documentation now. Feel free to comment on my not very documentation-like writing style.

@mamazu mamazu requested a review from a team as a code owner August 13, 2019 20:09
Copy link
Member

@lchrusciel lchrusciel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Thank you very much!

doc/Cookbook.md Outdated Show resolved Hide resolved
doc/Cookbook.md Outdated Show resolved Hide resolved
doc/Cookbook.md Outdated Show resolved Hide resolved
doc/Cookbook.md Outdated Show resolved Hide resolved
doc/Cookbook.md Outdated Show resolved Hide resolved
doc/Cookbook.md Outdated Show resolved Hide resolved
doc/Cookbook.md Outdated Show resolved Hide resolved
doc/Cookbook.md Outdated Show resolved Hide resolved
doc/Cookbook.md Outdated Show resolved Hide resolved
doc/Cookbook.md Outdated Show resolved Hide resolved
Copy link
Member

@lchrusciel lchrusciel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/cc @CoderMaggie, would you like to take a look, once you have a free moment?

doc/Cookbook.md Outdated Show resolved Hide resolved
doc/Cookbook.md Outdated Show resolved Hide resolved
doc/Cookbook.md Outdated Show resolved Hide resolved
doc/Cookbook.md Outdated Show resolved Hide resolved
@mamazu mamazu changed the title Adding a Cookbook [WIP] Adding a Cookbook Aug 14, 2019
@mamazu
Copy link
Member Author

mamazu commented Aug 14, 2019

Adding information about Serialization

This was referenced Aug 14, 2019
Copy link
Contributor

@CSchulz CSchulz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey mamazu,

I have just read your cookbook and it looks good to me. I have added some comments and thoughts.
Even if they sound a little bit rude, they are not supposed to be. 😓

I haven't much experience with Sylius perhaps some comments are really newbish.

doc/Cookbook.md Show resolved Hide resolved
doc/Cookbook.md Outdated Show resolved Hide resolved
doc/Cookbook.md Outdated Show resolved Hide resolved
doc/Cookbook.md Outdated Show resolved Hide resolved
doc/Cookbook.md Outdated

## How does the Shop Api work
<img src="Workflow.png" alt="Apis Workflow" />
The general approach that Shop Api takes is that every request is validated by the `CommandProvider` and then converted into a command by this class. Then the command is either handled directly in the `Controller` and passed to the `ViewRepository` which returns a view or by a `MessageHandler`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to add here some links to the different variants. I think the MessageHandler is part of the Messenger framework, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes in the MessageHandler section there is a link to the symfony configuration of this tool.

doc/Cookbook.md Outdated Show resolved Hide resolved
doc/Cookbook.md Outdated Show resolved Hide resolved
doc/Cookbook.md Outdated Show resolved Hide resolved
doc/Cookbook.md Show resolved Hide resolved
doc/Cookbook.md Outdated Show resolved Hide resolved
@mamazu
Copy link
Member Author

mamazu commented Aug 14, 2019

@CSchulz Thanks for your feedback, having no knowledge about the api is the best thing, if you are reading through documentation. I have improved on your suggestions. Could you have a look at it again.

@CSchulz
Copy link
Contributor

CSchulz commented Aug 16, 2019

Yes I will look into it at the weekend.

doc/Cookbook.md Outdated Show resolved Hide resolved
@lchrusciel
Copy link
Member

lchrusciel commented Sep 9, 2019

Hey Max,

it is probably the best description atm, so I think it would be great to add it to main repo. Rebase should fix the issue.

Also, can you add a link to docs from the main README?

Copy link
Contributor

@CSchulz CSchulz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have found some more questions, sorry for the late reply.

doc/Cookbook.md Outdated Show resolved Hide resolved
doc/Cookbook.md Outdated Show resolved Hide resolved
doc/Cookbook.md Outdated Show resolved Hide resolved
doc/Cookbook.md Show resolved Hide resolved
doc/Cookbook.md Show resolved Hide resolved
doc/Cookbook.md Outdated Show resolved Hide resolved
@mamazu mamazu changed the title [WIP] Adding a Cookbook Adding a Cookbook Sep 9, 2019
doc/Cookbook.md Outdated Show resolved Hide resolved
doc/Cookbook.md Outdated Show resolved Hide resolved
doc/Cookbook.md Show resolved Hide resolved
doc/Cookbook.md Show resolved Hide resolved
doc/Cookbook.md Show resolved Hide resolved
@diimpp
Copy link
Member

diimpp commented Sep 10, 2019 via email

@mamazu
Copy link
Member Author

mamazu commented Sep 10, 2019

True, Sylius Core handles it that way so this plugin should allow suit for the hostname resolution.
I have updated the documentation, any thoughts?

doc/Cookbook.md Outdated Show resolved Hide resolved
doc/Cookbook.md Outdated Show resolved Hide resolved
doc/Cookbook.md Show resolved Hide resolved
doc/Cookbook.md Show resolved Hide resolved
In the default implementation of the Sylius Solution, there is already an api implemented that provides a lot of features (which is called the Admin Api). The Admin Api is more geared towards integrating other closed systems like a warehouse management system or similar. The reason behind that is that for the Admin Api you need to have to [exchange tokens to authenticate](https://docs.sylius.com/en/latest/cookbook/api/api.html) a new client for usage (which is based on oauth). On the other side in the Shop Api everyone can log into Sylius who has an account, no token exchange necessary. The Shop Api uses the [JWT](https://github.com/lexik/LexikJWTAuthenticationBundle) to authenticate its users.

## How does the Shop Api work
<img src="Workflow.png" alt="Apis Workflow" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering why the request isn't mentioned in the workflow, perhaps you can also add it to the beginning.

@mamazu
Copy link
Member Author

mamazu commented Sep 16, 2019

This is the last iteration of the cookbook before 1.0

### Command - Handler Structure
Command handling has multiple parts to it. When dispatching a command, the `MessageBus` looks for a handler that has an `__invoke` method with the parameter type matching the type of the command that was dispatched. Before and after the handler is executed, there is a way for a "Middleware" to be executed (see below). The CommandHandler itself, however, does not return anything (this is not a technical limitation that is just the convention we chose in Shop Api).

All Middlewares which are executed are defined under the `framework.messenger` bundle: [config.yml](https://github.com/Sylius/ShopApiPlugin/blob/fc25f36274e6add118f5b575a44db81bcc47b2e5/src/Resources/config/app/config.yml#L17)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
All Middlewares which are executed are defined under the `framework.messenger` bundle: [config.yml](https://github.com/Sylius/ShopApiPlugin/blob/fc25f36274e6add118f5b575a44db81bcc47b2e5/src/Resources/config/app/config.yml#L17)
All Middlewares which are executed are defined under the `framework.messenger` bundle: [config.yml](https://github.com/Sylius/ShopApiPlugin/blob/master/src/Resources/config/app/config.yml#L17)

@lchrusciel lchrusciel merged commit c62c3f1 into Sylius:master Sep 21, 2019
@lchrusciel
Copy link
Member

Thanks, @mamazu! 🥇

@mamazu mamazu deleted the cookbook branch September 21, 2019 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants