filmov
tv
RESTful API - Part 5: Symfony Serializer and code refactor - PHP, Symfony 5, TDD

Показать описание
Fifth 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 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 integrating the Symfony's Serializer Component which will allow us to work with objects instead of arrays. As a result of this new approach a quite extensive refactor of our code will be needed, said refactor will help us improve our tests too!
Useful links:
Timestamps:
00:00 RECAP
00:33 Renaming classes, Providers become Repositories. (Dealing with Symfony's cache and composer autoload).
04:27 The red text in tests results, explanation from previous episodes
05:22 The actual repository refactor, introducing Symfony's Serializer
07:28 A "messed up" Serializer expanation
08:41 How we're going to use the Serializer
10:02 Default Serializer and custom configuration
10:42 The "dirty" way
12:09 The "elegant" way
20:17 Now that we have a Serializer, let's use it!
20:36 How I did it (explaining how I created the objects and forgot to hit record!)
24:58 BAD AUDIO ALERT!!! :( It's 7 minutes of awful audio, not sure what happened to my mic! :( you can skip to 37:31 if you can't stand it! :(
24:58 More refactoring, filtering by author
27:31 Refactor complete, let's fix the tests!
32:34 AUDIO BACK TO NORMAL! Yahaayyyy!!!
37:31 Last failing test (How using Dependency injection will help us getting rid of a Mock in PHPUnit)
44:00 What will come next!
We used using Docker to setup a local environment and we'll use Redis to cache responses.
I 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 integrating the Symfony's Serializer Component which will allow us to work with objects instead of arrays. As a result of this new approach a quite extensive refactor of our code will be needed, said refactor will help us improve our tests too!
Useful links:
Timestamps:
00:00 RECAP
00:33 Renaming classes, Providers become Repositories. (Dealing with Symfony's cache and composer autoload).
04:27 The red text in tests results, explanation from previous episodes
05:22 The actual repository refactor, introducing Symfony's Serializer
07:28 A "messed up" Serializer expanation
08:41 How we're going to use the Serializer
10:02 Default Serializer and custom configuration
10:42 The "dirty" way
12:09 The "elegant" way
20:17 Now that we have a Serializer, let's use it!
20:36 How I did it (explaining how I created the objects and forgot to hit record!)
24:58 BAD AUDIO ALERT!!! :( It's 7 minutes of awful audio, not sure what happened to my mic! :( you can skip to 37:31 if you can't stand it! :(
24:58 More refactoring, filtering by author
27:31 Refactor complete, let's fix the tests!
32:34 AUDIO BACK TO NORMAL! Yahaayyyy!!!
37:31 Last failing test (How using Dependency injection will help us getting rid of a Mock in PHPUnit)
44:00 What will come next!