Practice

Use a feature, right now

Short exercises, separate from the tracks: code written the old way, to rewrite with the feature. Often something new in the framework, sometimes a specific point worth a closer look.

  • 64 exercises
  • 55 new features

64 exercises · 1 to 20

Sort: Recent Title

By title

20
  1. Symfony 8.2 New A collection of blocks of several kinds PolymorphicCollectionType gives each entry of a collection the form of its kind: titles, paragraphs and quotes in the same page. Forms Do the exercise
  2. Symfony 8.2 New A form for an immutable object Symfony 8.2 calls the constructor of a readonly class: no more intermediate array or copied constraints, but a new object to read from getData(). FormsDTO Do the exercise
  3. Symfony 8.2 New A form that reads PHP types ->add('seats') is enough: Symfony 8.2 infers the field type and its empty_data from the property's type, and an empty field no longer causes a TypeError. Forms Do the exercise
  4. Symfony 8.2 New A generic page of results, Page<Produit> Symfony 8.2's Serializer understands PHPDoc generics: a single Page class, holding Produit or Avis objects depending on the property that carries it. SerializerAPI Do the exercise
  5. Symfony 8.2 New A JSON array in a text field, with allow_array_submission A text field receiving a JSON array was rejected before any listener. allow_array_submission lets PRE_SUBMIT transform it first. FormsAPI Do the exercise
  6. Symfony 8.2 New A link in a translation, without raw The trans_html filter replaces the pseudo-tags of a translation with HTML declared in the template, and escapes everything else, parameters included. TranslationTwigSecurity Do the exercise
  7. Symfony 8.2 New A login link that keeps its destination createLoginLink() now signs its parameters: the return_to of a login link can no longer be tampered with. Security Do the exercise
  8. Symfony 8.2 New A reset link that only works once UriSigner::sign() accepts a “version”: sign the link with the password hash, and it dies as soon as the password changes. HttpFoundationSecurity Do the exercise
  9. Symfony 8.2 New A route that picks its firewall The firewall option of #[Route] hands a route to a firewall without touching its pattern, and entry_point_path sends anonymous users to the login page, with no class to write. SecurityFirewallRouting Do the exercise
  10. Symfony 8.2 New An expired link that doesn't end up on an error page A ?ExpiredSignedUriException argument receives the failure of #[IsSignatureValid]: the controller responds itself, without dropping the attribute. HttpKernelSecurity Do the exercise
  11. Symfony 8.2 New An expression that doesn't read your secrets constant() and enum() could read any constant of the application. ConstantFunctionProvider limits them to a list: a rule written in the back office can no longer guess an API key. ExpressionLanguageSecurity Do the exercise
  12. Symfony 8.2 New Ask for the right factor again instead of a 403 Vote::requestReAuthentication(): your voter can send the user to a new authentication, and the entry point chooses which one. Security Do the exercise
  13. Symfony 8.2 New Asking for the password again before sensitive pages IS_AUTHENTICATED_RECENTLY and IS_AUTHENTICATED_VERY_RECENTLY: a “sudo mode” that asks for the password again when the login is old. Security Do the exercise
  14. Symfony 8.2 New Change a secret without breaking the links already sent The secret of framework.uri_signer accepts a list: the first one signs new links, all of them check the ones still around. HttpFoundationSecurity Do the exercise
  15. Laravel 13.35 New Checking an event's contents with an array of properties assertDispatched() and assertPushed() accept an array of expected properties instead of a callback. TestingEventsQueues Do the exercise
  16. Laravel 13.31 New Checking that an email is sent only once assertSentOnce() and assertSentOnDemandOnce(): the Mail and Notification fakes finally say “exactly once” in one word. TestingMailNotifications Do the exercise
  17. Symfony 8.2 New Checking that an identifier exists, with #[EntityExists] #[EntityExists] checks that an identifier received by the API points to an entity: a clear 422 instead of a 500 error in the controller. ValidatorDoctrine Do the exercise
  18. Laravel 13.35 New Computed default values with defaults() The HasDefaultAttributes trait gives the model a defaults() method: default values that can read the configuration or the clock, as soon as new Abonnement runs. Eloquent Do the exercise
  19. Laravel 13.34 New Counting the rows of several tables in one assertion assertDatabaseCount() accepts an array: the expected number of rows in each table, checked in a single assertion. TestingDatabase Do the exercise
  20. Symfony Deleting an item removed from its order Removing an item from the collection doesn't delete it: orphanRemoval tells Doctrine that an item without an order has no reason to exist. DoctrineRelationsOneToMany Do the exercise