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

This week

7
  1. Symfony 8.2 New Grouping the steps of a multi-step form Symfony 8.2 nests the steps of a form flow: createStepGroup() brings the company and billing steps together, and a single setSkip() skips both for an individual. Forms Do the exercise
  2. Symfony 8.2 New The shop follows the whole import, with PropagatedStampInterface A stamp implementing PropagatedStampInterface is copied onto every message sent during handling, and the handler gets it as an argument: no more context to pass from message to message. Messenger Do the exercise
  3. 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
  4. Symfony 8.2 New Help text under each choice, with choice_help choice_help gives each radio button its own help text, linked by aria-describedby: short labels, and explanations that screen readers read with the right choice. FormsAccessibility Do the exercise
  5. 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
  6. 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
  7. 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

Earlier

13
  1. 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
  2. Symfony 8.2 New Pay, ship, and cancel if it breaks ChainStamp chains messages in order, and DispatchOnFailureStamp sends the cancellation whichever step fails: a saga in a single dispatch(). Messenger Do the exercise
  3. 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
  4. 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
  5. 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
  6. 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
  7. Symfony 8.2 New Validating according to the user's permissions is_granted() and current_user() in the When and Expression constraints: the rules that depend on the logged-in user leave the controller. ValidatorSecurity Do the exercise
  8. Symfony Protecting a delete action with a CSRF token A "Remove" link sent as a GET deletes the dish for the first bot that comes along: switch to POST, with a CSRF token for each dish. SecurityCSRFTwig Do the exercise
  9. Symfony Filtering without truncating collections A WHERE on a join loaded with addSelect() leaves collections incomplete, and they stay that way in the EntityManager. EXISTS filters without cutting anything. DoctrineRelationsQueryBuilderN+1 queries Do the exercise
  10. Symfony Paginating orders loaded with their items On a query with a join, setMaxResults() limits SQL rows, not entities: Doctrine's Paginator pages through orders without cutting their collections. DoctrineRelationsPaginationN+1 queries Do the exercise
  11. Symfony Never replace a Doctrine collection With orphanRemoval, a setItems() that replaces the collection wipes every item in the database, even the ones passed back to it. An adder keeps them. DoctrineRelationsOneToMany Do the exercise
  12. 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
  13. Symfony Saving an order with its items “A new entity was found through the relationship”: with cascade: ['persist'], a single persist() saves the order and its items. DoctrineRelationsOneToMany Do the exercise