Symfony === A Better Workflow

Probably the most requested feature for CodeReviewVideos right now is a search box.

Every time I get an email about this I feel like heading over to ShameNun.com and ringing the bell a few times. I know, I know, 2017, a site about programming, and I don’t even have a search bar 🙁

Well, the good news is: it is coming.

The bad news is: it’s not imminent.

I have a complete re-work of CodeReviewVideos living currently in my development environment. It follows all the practices I’ve been covering lately on the site:

There’s a bunch of other improvements in there too. Some are code related, others are things you will see when using the site.

Along the way, however, I’ve noticed I’m either going to have to take a risk with a server upgrade, or – more likely – do a side-by-side / DNS load balancer switcheroo. All of which adds to the complexity of the upgrade. This is a big part as to why this isn’t imminent. I don’t want to muck this up, so it requires a significant amount of planning.

Unfortunately back when starting the site I had only just started using Ansible, and whilst was happy to use it in my local / development setup, I didn’t have the confidence with it to manage my production servers. As such, CodeReviewVideos – in production – is not Ansible managed. Again, this will change with the upgrade, but it’s not quite as simple as running a single playbook and being bang up to date.

Anyway, it’s coming, so stay tuned 🙂

Video Update

This week there have been three new videos added to the site.

https://codereviewvideos.com/course/symfony-workflow-component-tutorial/video/creating-more-complex-workflows

First up we take a look at the example we will use throughout the rest of this series.

There isn’t as much code to learn with the Workflow Component as you might expect. There’s a few commonly used methods, some of which are also available in your Twig templates under slightly different names, but overall it shouldn’t take you that long to get familiar with the API.

What is harder – in my opinion – is the concepts behind the component. I would strongly recommend you take a look at this page:

http://workflowpatterns.com/patterns/control/

As this contains a bunch of useful ‘templates’ as to how you can put workflows together.

What I have found tricky is the naming conventions for transitions, and places. I would strongly recommend you follow along with this example, as we will cover on all the most commonly used transitions I have used in the real world. Getting hands-on is absolutely essential for building confidence in not only how to use this component, but also when it might be a good idea to do so.

https://codereviewvideos.com/course/symfony-workflow-component-tutorial/video/two-ways-to-make-life-easier-for-you-the-developer

As you will see a little later in this course, the Workflow Component dispatches a ton of events every time you successfully apply a transition.

Out-of-the-box, the Workflow Component comes with an Audit Trail Listener – a utility class you can hook up to start seeing stuff in your logs. This is fairly useful as a starting point. In a future video we will implement our own version of this Listener, as the generic one can only take you so far.

We’re also going to touch on the use of constants. As of Symfony 3.2 we can use PHP constants in YAML files (http://symfony.com/blog/new-in-symfony-3-2-php-constants-in-yaml-files).

The syntax is a little… well, it’s not my favourite. However, whilst using constants in your YAML files may look quite verbose, if you can get past this, the benefits do outweigh the negatives.

If you are using Twig then you can also use your constants in your templates too, so that’s another strong reason to do so.

https://codereviewvideos.com/course/symfony-workflow-component-tutorial/video/how-to-transitions-that-split-into-two-or-more-places

A really common workflow pattern I’ve found myself using in real world projects is the “AND-split” / “Parallel Split”.

My brain prefers the Friends style title: “the one where one place splits in to two, or more places”.

This has a few consequences further down the line – such as how to to merge back together, or not, and also how your state will be represented in your database.

I found this quite confusing when viewed as part of larger workflow diagrams, but fortunately when you break each transition down to their simplest forms, there’s really nothing scary going on here.

In this video we will also touch on how some of the workflow methods can trigger guards, which may result in some unexpected outcomes – but only if you aren’t aware of this, which of course you will be after watching this video 🙂

There’s still a good chunk to cover in this Workflow Component series, more of which is to come next week.

Until then, have a great weekend, and happy coding.

Chris

Published by

Code Review

CodeReviewVideos is a video training site helping software developers learn Symfony faster and easier.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.