Posts

  • Resolving values for unmapped properties when mapping request data to DTOs in Symfony 6.3+

    Ever since it was introduced, the functionality for mapping request data to DTOs has been my favourite Symfony 6.3 new feature. The new #[MapRequestPayload] and #[MapQueryString] attributes allow us to delegate the DTO instantiation to the framework, instead of doing it manually in the controllers - for example when instantiating commands to be dispatched to a command bus. However, I realized that most of the commands in my application contain additional properties which are not directly mapped to the request data - such as the ID of the currently authenticated user. In this article, we’ll see how we can enhance the process to be able to resolve the unmapped values in such cases.

    Read more...

  • Centralized exception handling with Symfony and custom PHP attributes

    Over time, as our application grows, the controllers can become cluttered with repeated exception handling code. In this article we’ll see how we can have both cleaner controller methods when using the Symfony framework by centralizing the exception handling, and cleaner domain exceptions by only declaring custom PHP attributes on their classes.

    Read more...

  • Experimental: Unpacking message properties as handler arguments in Symfony Messenger

    In my previous post, we saw that by using custom PHP attributes, we can have our Symfony Messenger message handlers placed in any service in our application. The only requirement for the message handlers is for them to be methods that are able to receive the message object as an argument. In this post we will see how we can avoid that requirement, and register any method as a message handler, by automatically passing any of the message’s properties as values for the handler’s arguments.

    Read more...

  • Using custom PHP attributes for registering and configuring Symfony Messenger handlers

    Symfony Messenger provides multiple ways for registration and configuration of message handlers. Nowadays, the handlers are usually registered by implementing the component’s MessageHandlerInterface interface, which makes the handlers auto-configurable by default, or by implementing some interface of ours which we can register for autoconfiguration manually. However, with the addition of the attributes functionality in PHP 8.0, it doesn’t really make sense anymore to use interfaces for the purpose of “describing” our classes. In this article we’ll explore how we can use our own PHP attributes to register and configure the message handlers.

    Read more...

  • PHP 8 Attributes example: Injecting the current user in Symfony controllers without the security component

    Although we’ve been using annotations in PHP for years, this functionality was not part of the language itself. Instead, we had to rely on parsing the comments formatted as docblocks above the classes, properties or methods, usually with the doctrine/annotations library. With the acceptance of the “Attributes v2” RFC for the next major PHP version, the concept will become part of the PHP core, called “Attributes” and with slightly different syntax: <<Example>> instead of @Example. In this article we’ll see how we can use a custom attribute to tell Symfony how to resolve the currently authenticated user as controller action argument even if we don’t use the security component.

    Read more...

  • Decomposing the user checking mechanism in Symfony

    The user checkers in the Symfony Security component allow us to control whether an user can be authenticated in our system, even if they have entered their correct credentials. In this article we’ll see how we can make the process more flexible by splitting our checking logic from one to multiple checkers.

    Read more...

  • Using the Go! Aspect-Oriented Framework to trim values before validation

    Few weeks ago, while using the NotBlank constraint from the Symfony Validator to validate a command before executing it, a co-worker of mine noticed that the values are not automatically trimmed, so it would allow strings of empty spaces to be passed as valid values.

    Read more...

  • On creating cleaner and simpler commands

    Commands, as part of the CQRS pattern, provide a clean way for representing intentions for changing some state in our application. We’ve been working with CQRS for some time and it helped us significantly improve the quality of our code base. Meanwhile, we learned a lot, but we also made some mistakes. In this article we’ll discuss some of the mistakes we were making when using commands and what we did to improve them.

    Read more...

  • Symfony3 Form Component and type hinting in PHP 7.0

    Type hinting the methods’ arguments and declaring their return types is one of the best improvements that came with PHP 7. When I finally got a chance to play with it in an experimental side project using Symfony, I got stuck trying to combine the type hinting and the Symfony3 Form component.

    Read more...

  • Experimental upgrading to Laravel 5: How I did it

    When I started working on my biggest side project, the “EESTEC Platform for Local Committees” I introduced a few months ago, the latest stable version of Laravel was 4.2. Over the past weeks, Taylor introduced many great changes and new features that we’ll be able to use in the new version, firstly numbered 4.3 and later 5. According to the framework’s six month release cycle, it should had hit stable late this month or in early December. Because of that, I started to play with it and to apply the changes to make my application use it.

    Read more...

  • Introducing EESTEC Platform for Local Committees

    “EESTEC Platform” is a web application which will aim to ease the internal management of EESTEC’s local committees. The main idea for this to be achieved is to automate many of the tasks currently done “by hand” and to collect the big number of information (such as list of members and their info) currently spread across many spreadsheets, papers, mails etc. in one place.

    Read more...

  • Анализа на .mk домените до декември 2013

    Пред околу 3 месеци, од 01.10.2013 год. конечно на сила стапи новиот правилник за организација и управување со врвниот македонски .mk домен (претходниот правилник бил креиран во 1995 год.). Со овие домени, покрај Македонската академска истражувачка мрежа (МАРнет), од сега ќе можат да управуваат и компаниите кои ќе добијат статус на регистрари.

    Read more...

  • IMW: 10 years of EESTEC LC Skopje

    In the last few months my activities with EESTEC drastically decreased. I wanted to see the people again so I decided to join them in Ohrid on the first International Motivation Weekend organized by EESTEC LC Skopje from 18 to 21st of July. The event was also part of the bigger event called “EESTECers gone wild 2″. This IMW is important for the LC because it was mainly organized in order to celebrate the LC’s 10th birthday.

    Read more...

  • EESTEC Motivational Weekend October 2012

    When I joned EESTEC (LC Skopje) about half year ago, almost all of the existing members were talking to me about some event called “Motivational weekend”. Few weeks after that, in May, we went on the first EESTEC motivational weekend for 2012 in Mountain house “Vrteska” on the mountain Plackovica. Today, I just got back from my second motivational weekend, held in the Mountain house “Smreka” on Popova Sapka from 05 to 07 October.

    Read more...