This is a conference report for my company:

Hi all,

I visited SymfonyLive Cologne 2016 conference last week. It was really well-organised and with the subject area was not limited just to Symfony.

”REST Services with Symfony” was a whole-day workshop lead by Christopher Hertel. There was a lot of theoretical knowledge about Symfony as HTTP framework, about REST, its levels of maturity, and generally how to REST correctly. We played with manually creating RESTful controllers and looked into internals of FOSRestBundle which generates them automatically.

Another whole-day workshop was ”Maintainable Doctrine ORM Applications” by Marco Pivetta. It actually was neither Symfony- or Doctrine-specific. We learned an approach to creating database schemas that is considerably different from what I’m used to doing, including:

  • avoiding auto-increment IDs in favour of UUID
  • using Value Objects, for instance: Book->isbn property that doesn’t store just an integer, but instead an instance of ISBN class, which has a private constructor and built-in validation. It requires a custom Doctrine type for every value like that, but also makes the code clearer.
  • avoiding getters and setters in favour of behavioural methods, like (User#ban() or Book#lend(User)) - it’s more expressive and ensures that your entity is always valid, but IMO it demands too much overhead: those accessors are required by forms, serialisers etc., so you need to create additional DTOs and copy-paste data from them to an actual entity and vice versa.
  • an idea of an “Aggregate” – a set of connected entities, from which only one (called aggregate root) is allowed to be publicly accessed (for instance a Library encapsulates all its books and all the book’s landings, not allowing anyone else to create an instance of Lending or Book entity themeselves).

Bernhard Schussek held a talk ”Symfony Forms: Dos and Don’ts”, and it showed exactly what the title promised, focusing mostly on the most recent changes in the symfony/forms component in the version 3.0.

”Maßgeschneiderte Testdaten mit Faker und Alice” by Philipp Rieber was a presentation about fake-data generator libraries: Faker and Alice. The first one is used in Skyrocket (well, a bit), it provides a large number of generators, like names, surnames, addresses, phone numbers, identification numbers, IBANs, ISBNs, etc., many of which are locale-specific. Really powerful tool. It is just a plain PHP, though, and not so neat to use. Alice is a library that extends its power and allows you to create very expressive YAML fixture files with nice and easy relations management. Check out an example of what it can do: https://github.com/nelmio/alice#example

Benjamin Eberlei in ”Go lernen für einen Symfony Websocket Proxy” showed an example of when is it useful to be polyglot - he explained why is a language like Go suited to handle a web socket server and how to communicate it with PHP application. A simple example can be seen here: https://github.com/beberlei/websocket-proxy-example

”Modernisieren mit Symfony” by Alexander M. Turek showed an idea of how to migrate some old legacy non-MVC code to a nice Symfony application. How to do it step-by-step and to have a functioning application at every moment of the refactoring. Basically, you need to adjust Symfony’s front controller, routing and security management in the way that SF tries to execute a request first, and if it fails, it passes control to the legacy code.

Christoph Reinartz in ”Pattern Library meets Symfony” showed how did his team successfully migrate all their old unstructured CSS for Trivago, to The Pattern Library.

Remember the worst code you’ve ever seen. Then imagine an even worse one. That’s what Jan van Thoor showed us in his talk ”Open Heart Surgery”. Trivago’s PHP code was a total mess, with all the mistakes you can make: totally mixed up MVC layers, hell of dependencies, non descriptive method/var names, useless comments, all the business logic stuffed in one, long, extremely complex method, etc. etc. Jan showed us how his team managed to refactor that mess by iterated process of demarking modules of code, restructuring them just enough to be able to unit test them, and only after that actually refactoring the code.

Also, during the conference SensioLabs DE announced their new tool: Deptrac. It allows you to define (in a single YAML file) the layers of your application (like services, controllers, repositories etc.) and the rules regarding which layers are allowed to depend on which ones. Deptrac analyses the code, reports dependencies violations and draws a graph of layer dependencies. They’ve just put an announcement on SF’s blog as well: symfony.com/blog/clean-software-architecture-with-deptrac

Best Regards,
Andrzej