WEBVTT

NOTE Created by CaptionSync from Automatic Sync Technologies www.automaticsync.com

00:00:00.276 --> 00:00:16.966 align:middle
Hello! Welcome to my talk about leveraging
the power of Symfony within API Platform.

00:00:17.216 --> 00:00:20.326 align:middle
So first thing first I'm
going to introduce myself.

00:00:20.326 --> 00:00:24.516 align:middle
So I'm Antoine Bluchet also
known as soyuka online.

00:00:25.366 --> 00:00:29.886 align:middle
And I'm core contributor to
API Platform, but also PM2,

00:00:29.966 --> 00:00:33.396 align:middle
which is a Node.js Process management software.

00:00:34.036 --> 00:00:41.446 align:middle
And I'm developing or coding in many
languages, php, Node.js, also a bit of Rust.

00:00:41.446 --> 00:00:43.696 align:middle
And I play Rocket League.

00:00:44.556 --> 00:00:49.416 align:middle
Um, so which one you guys don't...

00:00:49.416 --> 00:00:53.126 align:middle
doesn't know about API Platform
here in this room?

00:00:54.496 --> 00:00:55.176 align:middle
Doesn't know.

00:00:56.566 --> 00:00:59.266 align:middle
Okay. Yeah, that's good, a few hands.

00:00:59.886 --> 00:01:05.586 align:middle
So "API Platform is the most advanced API
platform in any framework or language".

00:01:05.986 --> 00:01:10.866 align:middle
So this is a quote of Fabien Potencier
from last year at the SymfonyCon.

00:01:11.166 --> 00:01:14.106 align:middle
So what is actually API Platform?

00:01:14.666 --> 00:01:24.056 align:middle
It's basically a set of tools and these tools
are given to you, and give you the ability

00:01:24.056 --> 00:01:27.266 align:middle
to build an API in really a few minutes.

00:01:29.566 --> 00:01:36.406 align:middle
So for example, yeah, we have create,
remove, update, delete resource management.

00:01:37.066 --> 00:01:44.286 align:middle
Uh, we have embedded filtering, sorting,
we have the validation that comes

00:01:44.286 --> 00:01:46.796 align:middle
from the symfony/validator component.

00:01:47.026 --> 00:01:51.166 align:middle
We have pagination, authentication, for example,

00:01:51.496 --> 00:01:56.976 align:middle
with the JSON Web Tokens or
OAuth and things like this.

00:01:57.976 --> 00:02:04.226 align:middle
In these tools are also available the security.

00:02:04.746 --> 00:02:10.706 align:middle
So when you think about an API, you don't really
think about security and you don't have to care

00:02:10.706 --> 00:02:13.076 align:middle
about it because we did all the work.

00:02:13.076 --> 00:02:14.186 align:middle
We prepared this for you.

00:02:14.706 --> 00:02:23.706 align:middle
What's important is that we are using
this JSON Linked Data format by default,

00:02:23.706 --> 00:02:28.606 align:middle
but you can use any format
that you want CSV, XML,

00:02:28.956 --> 00:02:33.206 align:middle
everything that the symfony/serializer
component gives you.

00:02:33.206 --> 00:02:38.716 align:middle
API Platform has Hypermedia capabilities.

00:02:38.866 --> 00:02:40.766 align:middle
I'm going back to this in a minute.

00:02:41.726 --> 00:02:48.656 align:middle
And we also have GraphQL support, cache
abilities with Varnish for example.

00:02:50.956 --> 00:02:55.826 align:middle
Hypermedia capabilities means that
we can generate things for you.

00:02:55.976 --> 00:03:02.836 align:middle
For example, this Open API, it
used to be called SwaggerUI.

00:03:03.656 --> 00:03:12.566 align:middle
Um, we have also this, uh, admin panel you
can put on API Platform, you mount your API,

00:03:12.566 --> 00:03:18.956 align:middle
then you just run a few commands and you
have an admin built out of React Admin.

00:03:19.546 --> 00:03:24.746 align:middle
We have code generators, for example, for
React, also React Native since a few weeks.

00:03:25.436 --> 00:03:29.986 align:middle
Uh, Angular interfaces for typescript.

00:03:31.056 --> 00:03:32.906 align:middle
And it's production ready.

00:03:33.426 --> 00:03:38.836 align:middle
Uh, the, there are lots of companies, I'm
sure you're aware of because you're using it,

00:03:39.326 --> 00:03:42.176 align:middle
that are using API Platform in production.

00:03:42.516 --> 00:03:44.156 align:middle
And it does really work well.

00:03:44.336 --> 00:03:52.176 align:middle
For this to work, we have a Docker, a
docker container that's all ready for you.

00:03:52.176 --> 00:03:56.916 align:middle
You just have to clone the repository
launch it and you're ready for production.

00:03:59.036 --> 00:04:01.696 align:middle
So API Platform is also open source.

00:04:01.696 --> 00:04:03.896 align:middle
So this is really, really great.

00:04:04.456 --> 00:04:09.096 align:middle
Today, so I've combined, we have two
repositories, we have the core one

00:04:09.366 --> 00:04:13.016 align:middle
and API platform with, which
is a bit front page.

00:04:13.656 --> 00:04:22.716 align:middle
I combined them both and we have
about 2,900 commits, 140 contributors.

00:04:22.716 --> 00:04:24.016 align:middle
So thank you very much for this.

00:04:24.636 --> 00:04:31.816 align:middle
Uh, about 3000 stars and we just reached
a million downloads a few weeks ago.

00:04:31.816 --> 00:04:36.786 align:middle
So I was checking like two days ago
on the Packagist website and yeah,

00:04:36.786 --> 00:04:41.016 align:middle
we just reached a million
downloads on the core repository.

00:04:41.376 --> 00:04:46.106 align:middle
So this is a really great milestone.

00:04:46.106 --> 00:04:51.546 align:middle
And now about this talk, it's
the thing is with API Platform is

00:04:51.546 --> 00:04:53.896 align:middle
that it benefits from the Symfony ecosystem.

00:04:54.686 --> 00:04:55.976 align:middle
So what does this mean?

00:04:55.976 --> 00:05:02.366 align:middle
Actually? It means that because
it's built in a Symfony way,

00:05:02.806 --> 00:05:09.806 align:middle
you can use every component you want
within API platform and really they combine

00:05:09.806 --> 00:05:13.786 align:middle
with each other really, really
in a simple manner.

00:05:16.136 --> 00:05:21.126 align:middle
So basically now for those who didn't
know about API platform before,

00:05:21.126 --> 00:05:24.926 align:middle
I hope that's what you're
thinking right now and yeah,

00:05:24.926 --> 00:05:30.656 align:middle
I just advise you to check API
Platform and just try to use it.

00:05:31.166 --> 00:05:32.926 align:middle
If you don't like it, it's okay.

00:05:32.926 --> 00:05:35.966 align:middle
But really I'm sure you will.

00:05:38.556 --> 00:05:43.646 align:middle
So now let's order pizza because we all like it.

00:05:45.976 --> 00:05:50.846 align:middle
To order pizza usually you
take your phone, I don't know,

00:05:50.846 --> 00:05:53.956 align:middle
you give a call, whatever, you order.

00:05:54.906 --> 00:05:58.986 align:middle
Then the pizza gets prepared
and then it gets delivered.

00:05:59.866 --> 00:06:02.016 align:middle
So this is what I call a workflow.

00:06:03.116 --> 00:06:13.626 align:middle
And then about this workflow is when the
user just sent out the command to call,

00:06:14.146 --> 00:06:19.316 align:middle
to order for a pizza, we need to notify the
kitchen and say: "hey, prepare my pizza please".

00:06:19.786 --> 00:06:25.466 align:middle
The kitchen prepares the pizza
and then it sends a message back.

00:06:25.466 --> 00:06:29.676 align:middle
okay, my pizza is ready, just
now we need to deliver it.

00:06:29.896 --> 00:06:34.676 align:middle
Now there is a second message that goes through
the delivery truck, for example, and says, okay,

00:06:34.676 --> 00:06:37.506 align:middle
my pizza needs to get to my client.

00:06:40.026 --> 00:06:47.016 align:middle
So, um, to do this, we're going to
base our project on symfony/skeleton.

00:06:47.436 --> 00:06:49.376 align:middle
So this is what I did here.

00:06:49.866 --> 00:06:54.246 align:middle
So I don't know if you heard about
Symfony4, and I insist on the 4

00:06:54.246 --> 00:06:56.636 align:middle
because we have now Flex recipes.

00:06:57.216 --> 00:06:58.656 align:middle
What are Flex recipes?

00:06:58.846 --> 00:07:07.366 align:middle
These are kind of like Composer plugins that
the third line here, the composer require api is

00:07:07.366 --> 00:07:16.756 align:middle
in fact, um, launching a Flex recipe
that will install API Platform,

00:07:16.756 --> 00:07:21.916 align:middle
but also the doctrine-bundle, CORS support
- Cross Origin Resource Management -

00:07:22.286 --> 00:07:26.616 align:middle
and everything you need to
basically have an API started.

00:07:27.136 --> 00:07:32.636 align:middle
So these three steps, and I'm
done, I've created an API.

00:07:32.636 --> 00:07:35.146 align:middle
All I need to do is add some stuff.

00:07:35.976 --> 00:07:42.396 align:middle
So really you could have started
the API Platform with our skeleton.

00:07:42.686 --> 00:07:47.136 align:middle
So check it out on Github it's the
api-platform/api-platform project.

00:07:47.756 --> 00:07:57.216 align:middle
But I prefer to use the symfony/skeleton
just to show you guys how things go together.

00:07:57.216 --> 00:08:03.986 align:middle
So now that we have API, I'm going to
start by installing the Workflow component.

00:08:04.446 --> 00:08:09.826 align:middle
So I don't know if you guys assisted to this,
the talk tomorrow, this morning about Workflow.

00:08:10.166 --> 00:08:14.546 align:middle
So yeah, basically this is
a quote from the docs.

00:08:15.116 --> 00:08:21.866 align:middle
And... so, yea: just require
it on top of our current API.

00:08:22.846 --> 00:08:26.966 align:middle
So really nothing really new here.

00:08:27.516 --> 00:08:31.436 align:middle
Um, next thing we're going to
use the Messenger component.

00:08:31.936 --> 00:08:37.456 align:middle
He also, we had a beautiful talk this
morning by Sam about the Messenger component.

00:08:38.556 --> 00:08:45.266 align:middle
And I actually stole a slide from
him, just like this afternoon.

00:08:45.656 --> 00:08:50.126 align:middle
And yeah, we are going to use really
basic functionalities because all we need

00:08:50.126 --> 00:08:53.286 align:middle
to do is send a message to the
kitchen and to the delivery truck.

00:08:53.716 --> 00:09:02.316 align:middle
So we have a message, we have the bus and the
bus will manage the, the to send the message

00:09:02.946 --> 00:09:08.676 align:middle
and then through our transport,
handlers will get this message.

00:09:09.406 --> 00:09:13.546 align:middle
I will get back to this.

00:09:14.606 --> 00:09:16.886 align:middle
Yea, easy: composer require symfony/messenger.

00:09:17.656 --> 00:09:20.496 align:middle
I remind you, I'm in a symfony/skeleton project.

00:09:20.826 --> 00:09:24.136 align:middle
I installed api, workflow and messenger.

00:09:25.866 --> 00:09:31.446 align:middle
So now, um, if I want to order
pizza, I thought about it

00:09:31.446 --> 00:09:34.076 align:middle
and I come, came out with this graph here.

00:09:34.506 --> 00:09:37.886 align:middle
So the first step on the top
left is just create an order.

00:09:38.016 --> 00:09:41.176 align:middle
To do so we're just doing a POST on our API.

00:09:41.176 --> 00:09:49.686 align:middle
Then the second step, when there is this
small message Emoji, it's actually a message

00:09:50.036 --> 00:09:55.076 align:middle
that we are sending from our API
to the kitchen in the bottom.

00:09:55.606 --> 00:10:03.296 align:middle
When the pizza is done, the kitchen will
answer: "okay, API, I'm done, I'm ready".

00:10:03.826 --> 00:10:07.526 align:middle
The pizza is ready: PATCH /orders/prepare.

00:10:08.606 --> 00:10:12.606 align:middle
The fourth step is, then again, I'm
sending a message to the delivery truck.

00:10:13.356 --> 00:10:17.946 align:middle
And when the order has been delivered,
the delivery truck will answer.

00:10:18.196 --> 00:10:20.576 align:middle
So let's do this.

00:10:21.156 --> 00:10:24.126 align:middle
Um, just to remind, yea, this is the stack.

00:10:24.126 --> 00:10:26.446 align:middle
So Symfony, API Platform.

00:10:26.696 --> 00:10:29.976 align:middle
I'm using RabbitMQ for the
transport of my queues.

00:10:30.736 --> 00:10:39.316 align:middle
Um, and SQLite because I'm a lazy guy, I
didn't want to set up a PostgreSQL database.

00:10:40.216 --> 00:10:44.506 align:middle
So to do the first step, it's the easiest one.

00:10:44.756 --> 00:10:47.176 align:middle
All we have to do is create an entity.

00:10:47.586 --> 00:10:50.596 align:middle
So in src/Entity/Order.php.

00:10:50.596 --> 00:10:55.536 align:middle
basically most of you guys I hope
know about the annotation there.

00:10:55.976 --> 00:11:02.146 align:middle
So we have basic Doctrine annotations
and the most important one on the top

00:11:02.146 --> 00:11:06.186 align:middle
of the screen here is the @ApiResource.

00:11:07.906 --> 00:11:12.146 align:middle
In my Order, it's really simple:
for now I just have a status.

00:11:12.846 --> 00:11:17.716 align:middle
It was, yeah, you would have many
more fields like what pizza we want,

00:11:17.716 --> 00:11:24.666 align:middle
and what the are products,
etc. And yeah, it's done.

00:11:24.666 --> 00:11:27.766 align:middle
I have an API: I have my four routes.

00:11:28.106 --> 00:11:32.346 align:middle
So API Platform automatically creates
these when I create my entity.

00:11:32.966 --> 00:11:37.046 align:middle
I have GET on the collection,
then I can create a new one,

00:11:37.476 --> 00:11:41.826 align:middle
gets an item that exists,
update it or delete it.

00:11:43.386 --> 00:11:45.006 align:middle
So far so good.

00:11:47.176 --> 00:11:48.666 align:middle
Now, the workflow.

00:11:49.116 --> 00:11:56.436 align:middle
So to do the workflow, I hope you've
seen the conference this morning,

00:11:56.436 --> 00:11:57.566 align:middle
it was really interesting.

00:11:57.986 --> 00:12:02.176 align:middle
I want, I will not get into
details, but basically all you have

00:12:02.176 --> 00:12:05.196 align:middle
to do is, to set up this configuration.

00:12:06.016 --> 00:12:11.046 align:middle
What is really great is when we did
the composer require symfony/workflow,

00:12:11.306 --> 00:12:15.566 align:middle
we have a recipe behind it and it
preconfigured everything: this file existed.

00:12:15.846 --> 00:12:19.196 align:middle
I just had to go in there and add my things.

00:12:19.966 --> 00:12:24.866 align:middle
So I've added a few places
and a few transitions.

00:12:25.596 --> 00:12:31.656 align:middle
Uh, the cancel one isn't really important, but
yeah, just to show you guys how easy this was.

00:12:34.626 --> 00:12:40.486 align:middle
And yeah, that's nice with the workflow
as, I don't remember the speaker name

00:12:40.486 --> 00:12:43.506 align:middle
from this morning, but he
showed this command as well.

00:12:43.906 --> 00:12:47.846 align:middle
And he said something really
interesting is that: when you do this,

00:12:47.846 --> 00:12:53.456 align:middle
you can actually see what you
previous configuration gives.

00:12:54.016 --> 00:13:01.436 align:middle
And I did this many, many times and I'm,
I actually was okay: I will rename things

00:13:01.436 --> 00:13:08.166 align:middle
because transitions were, had bad names, etc.
And this is the result of the previous command.

00:13:08.526 --> 00:13:13.256 align:middle
So we can see we have a first
state is the order being ordered,

00:13:14.106 --> 00:13:17.056 align:middle
then the preparation, order get...

00:13:17.246 --> 00:13:18.136 align:middle
is prepare.

00:13:18.716 --> 00:13:21.066 align:middle
We deliver it and it's been delivered.

00:13:21.066 --> 00:13:27.536 align:middle
Now let's talk about the messages.

00:13:28.276 --> 00:13:38.596 align:middle
So to do this: same thing, all we have to
do is just prepare this configuration file.

00:13:39.756 --> 00:13:46.996 align:middle
On top of it you can see that I used,
yeah, I put out the environment variable

00:13:46.996 --> 00:13:54.576 align:middle
that I'm using below and I'm
specifying an amqp queue in RabbitMQ.

00:13:54.706 --> 00:14:03.366 align:middle
We, the small thing I added there is the
serializer configuration path, where I said:

00:14:03.366 --> 00:14:09.606 align:middle
okay, I'm in an API, I actually want
you to serialize things with JSON-LD.

00:14:10.106 --> 00:14:12.476 align:middle
The rest is just like in the documentation.

00:14:13.276 --> 00:14:17.356 align:middle
And to picture it, well I have
two transports: one is my kitchen.

00:14:17.356 --> 00:14:23.076 align:middle
So you really need to picture this
transport as different physically places.

00:14:23.596 --> 00:14:29.116 align:middle
The kitchen is really a kitchen and the
delivery truck is a delivery truck and I chose

00:14:29.116 --> 00:14:32.606 align:middle
to route my two messages
- the preparation message

00:14:32.706 --> 00:14:36.136 align:middle
and the deliver message -
to these two transports.

00:14:40.496 --> 00:14:46.546 align:middle
Now that we have this, we can create our
command but we still need to send this message

00:14:46.546 --> 00:14:50.606 align:middle
to the kitchen and say: Hey, I have an
order now, please prepare my pizza".

00:14:51.236 --> 00:14:56.486 align:middle
To do this, I've chosen to
add a Doctrine listener.

00:14:56.946 --> 00:15:02.346 align:middle
So I added the annotation there:
@EntityListeners OrderCreateListener.

00:15:02.926 --> 00:15:11.446 align:middle
So every time an order gets created with a POST,
on POST on my API, I'm just able to do things.

00:15:12.176 --> 00:15:17.616 align:middle
And here, I'm just dispatching
the message: PrepareOrderMessage.

00:15:18.396 --> 00:15:21.576 align:middle
So I injected the MessageBusInterface

00:15:22.506 --> 00:15:27.726 align:middle
and on postPersist I am saying
dispatch my PrepareOrderMessage.

00:15:31.206 --> 00:15:37.356 align:middle
So, this PrepareOrderMessage is
just a wrapper around my Order.

00:15:38.056 --> 00:15:45.666 align:middle
So, um, uh, this morning, Samuel
told us about the Messenger component

00:15:46.116 --> 00:15:52.326 align:middle
and new things that's evolved
since the 4.1 version of Symfony.

00:15:52.856 --> 00:15:59.196 align:middle
And so they might be, it may
be a bit simplified here.

00:16:00.736 --> 00:16:04.706 align:middle
And next step: we have this Order handler.

00:16:04.776 --> 00:16:06.726 align:middle
So this is actually my kitchen.

00:16:07.306 --> 00:16:13.456 align:middle
The kitchen will get messages in this
__invoke() function, it will prepare the pizza,

00:16:14.226 --> 00:16:22.146 align:middle
and when it's done, it will just send
an order via the API route with a PATCH.

00:16:26.536 --> 00:16:28.036 align:middle
Let's do this actually.

00:16:28.726 --> 00:16:31.566 align:middle
We don't have this PATCH /orders/prepare route.

00:16:31.566 --> 00:16:33.966 align:middle
We need to create it.

00:16:35.286 --> 00:16:40.046 align:middle
So with API platform it's
really easy to add a new routes.

00:16:40.116 --> 00:16:44.346 align:middle
So if you remember, at first I had four one's:

00:16:44.346 --> 00:16:48.746 align:middle
one to get the collection,
items, to delete and to update.

00:16:49.146 --> 00:16:53.936 align:middle
So I'm specifying itemOperations
with my previous routes

00:16:54.616 --> 00:16:59.756 align:middle
and I'm giving a new one called status
where I say: okay, this has a PATCH method.

00:17:00.556 --> 00:17:09.116 align:middle
And in the path I have my order, the id of
this order, and the transition I want to apply.

00:17:10.116 --> 00:17:17.416 align:middle
And the last one, the most
Important one, the controller class.

00:17:17.586 --> 00:17:19.376 align:middle
And this is how my controller is.

00:17:20.366 --> 00:17:22.256 align:middle
Um, it's a Symfony controller.

00:17:22.256 --> 00:17:24.776 align:middle
I hope you all know how it looks like.

00:17:25.256 --> 00:17:33.136 align:middle
I've injected my workflow Registry and whenever
I get a PATCH on this new route, I'm saying:

00:17:33.196 --> 00:17:35.376 align:middle
okay, get me the workflow please.

00:17:35.626 --> 00:17:39.466 align:middle
And just apply the transition
I got in my arguments.

00:17:41.656 --> 00:17:45.176 align:middle
Also I added some noise there
with the HttpException.

00:17:47.896 --> 00:17:50.166 align:middle
So we can now patch our orders.

00:17:50.686 --> 00:17:57.236 align:middle
The kitchen can say: okay, I have done, just
do the prepare transition because you're done.

00:17:57.916 --> 00:18:01.246 align:middle
Now we are going to do the exact
same thing with the delivery.

00:18:02.446 --> 00:18:04.906 align:middle
And, sorry, what, what's it...

00:18:05.056 --> 00:18:11.466 align:middle
what is really good here is that we
used a workflow to picture our process.

00:18:11.906 --> 00:18:18.766 align:middle
So what comes with the workflow is actually
a lot of events that again, we use behind it.

00:18:19.136 --> 00:18:21.196 align:middle
And this is exactly what I'm going to do now.

00:18:21.606 --> 00:18:28.496 align:middle
I'm going to say, okay, whenever the pizza
has been prepared, please send the message

00:18:28.496 --> 00:18:31.966 align:middle
for the delivery truck and
say: okay, the pizza is done.

00:18:31.966 --> 00:18:34.346 align:middle
Now you have to deliver.

00:18:34.346 --> 00:18:39.406 align:middle
So this is a listener, or can't be more simpler.

00:18:40.206 --> 00:18:44.546 align:middle
And at the bottom you can see
that the subscribe events I say:

00:18:44.906 --> 00:18:48.016 align:middle
workflow.order.transition.prepare
call onPrepare.

00:18:48.906 --> 00:18:55.946 align:middle
And the onPrepare will just get back to
order from the event and we will use this bus

00:18:55.946 --> 00:19:00.656 align:middle
to dispatch this new message:
please deliver my command.

00:19:03.216 --> 00:19:05.396 align:middle
So then again, exact same thing.

00:19:05.656 --> 00:19:10.426 align:middle
This is my delivery truck, this is
where I'm going to deliver my pizza.

00:19:10.686 --> 00:19:15.006 align:middle
Drive a bit, get to the client
and say, okay, here's your pizza.

00:19:15.386 --> 00:19:20.566 align:middle
And when it's done, I can get back
to my API and say, okay, I'm done.

00:19:20.606 --> 00:19:22.476 align:middle
I'm done delivering.

00:19:25.776 --> 00:19:27.956 align:middle
This was step five.

00:19:28.926 --> 00:19:34.326 align:middle
So now I'm going to show
you guys how this all works.

00:19:34.726 --> 00:19:36.116 align:middle
If I can find my screen.

00:19:36.156 --> 00:19:37.736 align:middle
Perfect. Nice.

00:19:38.286 --> 00:19:45.256 align:middle
So, as I said before, I actually
have an AMQP, a RabbitMQ service.

00:19:45.306 --> 00:19:55.466 align:middle
So here you can see on the
right, bottom right screen,

00:19:55.466 --> 00:19:59.196 align:middle
I have a RabbitMQ service that's
actually running right now.

00:19:59.546 --> 00:20:05.206 align:middle
And on the top left of the screen I'm going
to, uh, I want you to picture a kitchen.

00:20:05.206 --> 00:20:10.156 align:middle
So the top left of the screen is the kitchen
and I'm going to say: okay, consume message.

00:20:10.616 --> 00:20:16.076 align:middle
And yes, please consume the message
of my kitchen transport here.

00:20:16.686 --> 00:20:21.766 align:middle
So previously I routed the message,
PrepareOrderMessage, and I said: okay,

00:20:21.766 --> 00:20:23.516 align:middle
this message has to go to the kitchen.

00:20:24.006 --> 00:20:25.546 align:middle
So this is my kitchen.

00:20:26.006 --> 00:20:31.486 align:middle
And on the right side of the screen
I'm going to start my delivery truck.

00:20:33.256 --> 00:20:36.316 align:middle
Now, I'm just going to create an order.

00:20:36.986 --> 00:20:43.136 align:middle
So if you remind, I had only
one field, it was status order.

00:20:43.136 --> 00:20:46.256 align:middle
I'm hope you can see alright.

00:20:46.806 --> 00:20:56.626 align:middle
I can maybe increase the size a bit.

00:20:57.266 --> 00:21:08.356 align:middle
Yeah. So I'm using this tool httpie: it's just
curl: http POST on my API with new status order.

00:21:08.696 --> 00:21:11.386 align:middle
So status order is the first
step of my workflow.

00:21:11.956 --> 00:21:16.566 align:middle
So let's go and you can see the others done it.

00:21:16.816 --> 00:21:19.386 align:middle
It got created the kitchen prepared it

00:21:19.386 --> 00:21:25.936 align:middle
and now the delivery truck is delivering
it and he said, okay, I delivered.

00:21:25.966 --> 00:21:28.976 align:middle
So, I'm going to start this
again with a few commands

00:21:29.526 --> 00:21:31.616 align:middle
so that you can see everything in action.

00:21:32.026 --> 00:21:38.376 align:middle
So I've added, in my handlers, I've
set up a sleep time out with dots.

00:21:38.726 --> 00:21:43.526 align:middle
And when it's ready, I just
patched the order on my API.

00:21:56.396 --> 00:22:00.856 align:middle
Okay, so that just raises
further questions indeed.

00:22:01.336 --> 00:22:07.096 align:middle
Because here, I really wanted to show
you guys how easily things come together

00:22:07.096 --> 00:22:09.976 align:middle
when we use Symfony and API Platform.

00:22:10.436 --> 00:22:17.526 align:middle
The thing is, um, we could have used the
messenger and a lot more configuration possible.

00:22:17.526 --> 00:22:22.576 align:middle
And it goes the same with the workflow: it
can be really much more complicated than this.

00:22:23.316 --> 00:22:29.956 align:middle
What I actually don't really like about what I
did here is to use transitions through the API.

00:22:30.276 --> 00:22:35.516 align:middle
But yeah, this kind of things
can surely be improved.

00:22:36.506 --> 00:22:45.586 align:middle
Um, also about the transport, I used
here RabbitMQ on the messenger transport.

00:22:46.306 --> 00:22:52.356 align:middle
Uh, I've actually worked on the,
on a new transport with redis.

00:22:52.986 --> 00:22:57.006 align:middle
And uh, I've opened up a
pull request on Symfony.

00:22:57.556 --> 00:23:02.586 align:middle
So yeah, lots of thing that can
be improved in this workflow.

00:23:04.996 --> 00:23:12.016 align:middle
Um, actually what comes next now
is that within API platform also,

00:23:12.356 --> 00:23:14.066 align:middle
we will have the Mercure support.

00:23:14.066 --> 00:23:21.336 align:middle
So I don't know if you guys know about Mercure
yet, but it's something Kévin Dunglas worked

00:23:21.336 --> 00:23:28.426 align:middle
on that, that gives you the ability to receive
live events when you update a resource.

00:23:28.776 --> 00:23:34.266 align:middle
So for example, here, when I updated my
pizza, I could have received a live event

00:23:34.726 --> 00:23:39.926 align:middle
in the kitchen just by adding
one simple configuration

00:23:39.926 --> 00:23:43.696 align:middle
on my annotation, meaning mercure true.

00:23:44.096 --> 00:23:52.246 align:middle
In API Platform we also have, it's, it's
being prepared, it's the MongoDB support.

00:23:53.186 --> 00:23:59.076 align:middle
And we also have people working on
Elasticsearch read support within API Platform.

00:23:59.526 --> 00:24:02.706 align:middle
So lots and lots of new stuff.

00:24:02.706 --> 00:24:08.436 align:middle
We work everyday on API Platform to
provide you with the best tools possible.

00:24:10.676 --> 00:24:12.326 align:middle
So yeah, this was it.

00:24:12.326 --> 00:24:16.806 align:middle
So I want to thank the SymfonyCon
for having me here.

00:24:17.186 --> 00:24:22.856 align:middle
Uh, obviously, uh, everyone who contributed
to API Platform because I really learned a lot

00:24:23.366 --> 00:24:26.656 align:middle
by just reading you guys and working with you.

00:24:27.326 --> 00:24:35.316 align:middle
Uh, also, Les-Tilleuls, which
will be hiring me in February.

00:24:36.066 --> 00:24:40.556 align:middle
And yeah, this talk will be available
on GitHub soon, uh, at this URL.

00:24:40.556 --> 00:24:46.376 align:middle
And you can follow me on GitHub and Twitter.

00:24:46.856 --> 00:24:51.136 align:middle
So now if you have any question
I will be happy to answer them.

00:24:51.806 --> 00:25:07.276 align:middle
Does someone have a question?

00:25:10.336 --> 00:25:11.326 align:middle
I think this works.

00:25:12.076 --> 00:25:17.896 align:middle
Okay, I think it works.

00:25:18.166 --> 00:25:23.816 align:middle
I was wondering more about how can you
customize the API Platform because it seems

00:25:23.816 --> 00:25:26.456 align:middle
like it's like this, but perhaps not.

00:25:27.106 --> 00:25:29.726 align:middle
How you can customize API platform?

00:25:29.896 --> 00:25:34.026 align:middle
I mean, is this behavior that you
showed us, is it the standard behavior?

00:25:34.076 --> 00:25:35.746 align:middle
Can you do other things?

00:25:35.936 --> 00:25:42.646 align:middle
It's not a standard behavior because I used
other components that comes with Symfony.

00:25:43.106 --> 00:25:51.336 align:middle
But really when you have Symfony 4, with the
autoconfiguration and everything, it's so easy:

00:25:51.336 --> 00:25:54.026 align:middle
you just add the good interfaces
and everything works.

00:25:54.186 --> 00:25:58.356 align:middle
So, so I don't know.

00:25:58.596 --> 00:26:02.956 align:middle
Okay. Someone else back there?

00:26:03.546 --> 00:26:06.706 align:middle
Just send it and then.

00:26:07.136 --> 00:26:08.896 align:middle
It's like non-breakable mic.

00:26:09.256 --> 00:26:19.816 align:middle
Okay. Uh, for me it's questionable
for the monolith application, uh,

00:26:19.906 --> 00:26:24.806 align:middle
to use some additional services like
RabbitMQ and Redis for the messenger.

00:26:25.276 --> 00:26:31.266 align:middle
So I'm wondering if the same workflow
which you just showed can be achieved just

00:26:31.266 --> 00:26:35.876 align:middle
in the monolith with use of just Symfony events.

00:26:36.936 --> 00:26:42.116 align:middle
So you mean working with this
but with Redis on, in back?

00:26:42.116 --> 00:26:48.526 align:middle
No, without Redis and without RabbitMQ:
just with internal Symfony event system,

00:26:49.156 --> 00:26:54.416 align:middle
just in a monolith system, we are
working in a once call, right?

00:26:54.536 --> 00:27:01.116 align:middle
So no additional services
required usually in this case.

00:27:01.876 --> 00:27:08.056 align:middle
So actually, um, when you transport the
messages, you can use whatever you like.

00:27:08.056 --> 00:27:14.826 align:middle
I mean, yes, it can work, with a bit of work,
you'd have to dig a bit through the components,

00:27:14.906 --> 00:27:28.206 align:middle
but yeah, I don't see why
it couldn't, could not work.

00:27:29.646 --> 00:27:31.476 align:middle
Someone else.

00:27:32.006 --> 00:27:36.946 align:middle
Nope. Looks...

00:27:38.046 --> 00:27:44.526 align:middle
thank you for your attention.

