Create Three Symfony Back Ends - Part #7 - Symfony Form keeps you tidy

preview_player
Показать описание
Towards the end of the previous video we had a working Symfony controller class that could handle our POST data submission, and get us to a point where we had a plain PHP array containing the raw data that had been submitted.

An array is useful. However the data inside is not very "tidy".

The submitted date is a raw string. We can get Symfony to convert this for us to an instance of \DateTime, or \DateTimeImmutable, if that's your thing.

Once we've tidied up this submission, we need this data to "stick around". Which means we need to store it somewhere.

Sounds like a good use case for our pal Doctrine, no? It sure does, Kent.

If we're working with Doctrine, that means we need an entity to represent our data structure.

Don't be put off by the terminology, an Entity is simply a plain old PHP class on which one of the properties is an ID field.

Let's make our Album entity:

bin/console make:entity Album
Рекомендации по теме