filmov
tv
RESTful API - Part 2 - The Endpoint's controller (Symfony 5, Docker, Redis, PHPUnit, TDD) REAL TIME

Показать описание
Second episode of this short series where I'll try my best to walk you through the creation of a RESTful API with Symfony 5 (skeleton) in REAL TIME.
We used using Docker to setup a local environment and we'll use Redis to cache responses.
I'll use the TDD (Test Driven Development) approach where you write tests first to define the your objects' behavior which also helps obtaining a better design and test coverage. To do that I'm gonna be using PHPUnit, in particular the Symfony PHPUnit bridge package, and the Liip functional test bundle.
Far from me the idea of "teaching" programming to anyone. The point here is to provide a starting point to beginners and less experienced developers; I often find myself stuck or wondering on the best approach and in those circumstances Google, Stackoverflow and Youtube are your best friends, opening a window on other developers' ideas, opinions, best practices and approaches.
This wants to be my "little" way of giving back to the community.
In this episode we're creating the controller for the endpoint with the TDD approach. We'll discuss how to deal with data and how to define environment specific services in Symfony's Dependency Injection for our tests. As I recorded this coding sessions "live" you'll see how problems arise and how I deal with them, coming up with solutions and trying to improve the code as I go.
Useful links:
Timestamps:
00:00 Recap
02:40 First Functional Test (TDD Rules)
11:27 Planning the task
11:54 The Endpoint's controller
16:33 Mocks n' fixtures (Going the WRONG way with tests)
20:11 When everything goes wrong (a.k.a. Symfony's Dependency Injection Component)
21:57 Back in business and dealing with Json
29:26 Re-assessing how to proceed
31:34 More DI p*rn! (Configuring Environment specific services)
38:30 Back to the tests
42:05 Symfony's Dependency Injection (or the Router component) strike again: a.k.a. Fully Qualified Class Names vs. DI ids
44:17 The working Controller's test
45:37 Test missing required query parameter (and living with symfony's exceptions)
48:27 Final Recap
We used using Docker to setup a local environment and we'll use Redis to cache responses.
I'll use the TDD (Test Driven Development) approach where you write tests first to define the your objects' behavior which also helps obtaining a better design and test coverage. To do that I'm gonna be using PHPUnit, in particular the Symfony PHPUnit bridge package, and the Liip functional test bundle.
Far from me the idea of "teaching" programming to anyone. The point here is to provide a starting point to beginners and less experienced developers; I often find myself stuck or wondering on the best approach and in those circumstances Google, Stackoverflow and Youtube are your best friends, opening a window on other developers' ideas, opinions, best practices and approaches.
This wants to be my "little" way of giving back to the community.
In this episode we're creating the controller for the endpoint with the TDD approach. We'll discuss how to deal with data and how to define environment specific services in Symfony's Dependency Injection for our tests. As I recorded this coding sessions "live" you'll see how problems arise and how I deal with them, coming up with solutions and trying to improve the code as I go.
Useful links:
Timestamps:
00:00 Recap
02:40 First Functional Test (TDD Rules)
11:27 Planning the task
11:54 The Endpoint's controller
16:33 Mocks n' fixtures (Going the WRONG way with tests)
20:11 When everything goes wrong (a.k.a. Symfony's Dependency Injection Component)
21:57 Back in business and dealing with Json
29:26 Re-assessing how to proceed
31:34 More DI p*rn! (Configuring Environment specific services)
38:30 Back to the tests
42:05 Symfony's Dependency Injection (or the Router component) strike again: a.k.a. Fully Qualified Class Names vs. DI ids
44:17 The working Controller's test
45:37 Test missing required query parameter (and living with symfony's exceptions)
48:27 Final Recap
Комментарии