This week we’ve started two new series – one taking a beginners look at Git, and another covering the awesome Symfony Workflow Component.
The Git series is a member request. I’m always open to doing member requests, so do get in touch if you have a topic in mind.
I’ve wanted to record a series on the Workflow Component since – as best I can remember – at least a couple of months before Christmas. But there were two things stopping me:
- Lack of actually having used it 🙂
- Lack of understanding where I might use it
It took a determined effort on my part to finally find time to sit down, new up a Symfony project, and get started playing around with it.
In doing this, I took at look at the demo code (more on that below), and tried to work my way backwards, but came unstuck.
By starting with a new project and building up my knowledge incrementally, I was able to gather a momentum in learning much faster than I had initially anticipated. Isn’t this so often the case? New things seem scary and difficult when viewed as a whole, but when broken down into chunks and tackled piece by piece, suddenly things don’t seem quite so daunting.
Anyway in doing this I realised I was sitting on the solution to a problem in an app I’ve been working on for over a year now. I had this rather annoying situation whereby my app would run a cron job every minute to figure out if there was anything new to post out to social media. If there was, this would be added to RabbitMQ, which has an army of waiting workers, each designed to do one small task, and then pass on the responsibility downstream.
As part of this, the post could be in various stages – pending, posting, posted, failed, retrying – and I had managed, even in my small scale testing, to have found posts jumping about all over the shop – from pending to posted without ever posting, from pending to retrying without failing… the possibilities were annoying, and the outcome was one of frustration. I shelved my work on the app around August and vowed to return once I found a suitable solution.
In learning about the Workflow Component I was fairly sure I’d found a potential solution. I’m not saying simply adding a workflow definition solved my problems, but in doing so it did stop my entities from transitioning to invalid states. And when these transitions failed, I was able to more easily log out important information, and isolate the root cause of the problem. Actually the root cause turned out to be my lack of understanding of Rabbit MQ, but that’s a different story 🙂
This week saw three new videos added to the site:
First up we have an introduction to Git. In this series we cover all my most frequently used commands when working with Git on a day-to-day basis.
I use Git now for every project I do, and have done for at least the last three years. I still have a client who insists on SVN, and by comparison it is nothing but pain, fear, and frustration.
Anyway, I fully appreciate that when initially beginning with Git, it is akin to learning a whole new programming language. The good news is, much like in pretty much any programming language I have ever used, even though there are often 100s (if not 1000s) of commands / functions available, for most tasks you only ever need the same few.
Git is no different.
Sure, there are a bunch of advanced ways to use Git (submodules, anybody?) but mostly it’s just about adding, removing, committing, and pushing.
In this video we cover the most commonly used basics whether working alone, or in a team. In the next video we will cover branches, which whilst incredibly helpful if you’re working alone, become even more powerful – and potentially problematic – when working in a team.
Next up is the start of a new series covering Symfony’s Workflow Component.
This is a new component available either:
- ready-to-go in Symfony 3.2 onwards;
- or available as a third party bundle (fduch/workflow-bundle – https://github.com/fduch/workflow-bundle) if you’re still on Symfony 2.
As hinted at earlier, the Workflow Component is all about helping you manage the lifecycle / processes that your objects / entities go through as they pass through your system. Whilst that might sound a little dry / technical, the chances are you have some small, or large part of your existing and future projects that could readily benefit from using this tool.
To begin with we take a look at the rather brilliant Workflow Demo App that was created by Grégoire Pineau for his reveal of the Workflow Component at Symfony Live Paris 2016. In this video we will cover the two examples available – workflows, and state machines – and when and why you may wish to use each.
The Workflow Component brings with it a fantastic visual tool in the form of the Dumper, allowing you to output diagrams which represent the processes you’ve created via your Workflow definitions.
In the previous video you got to see both workflows and state machines in action.
However, whilst seeing the power of this component is useful, to get your head around how it all fits together is somewhat easier with a more basic example.
There’s loads of interesting things covered in this video – and starting with a new Symfony application you can code along and learn as you. It really is the very best way to inwardly digest this material.
By the end of this video you will have a good understanding of:
- how and why workflows and state machines differ
- how workflow definitions are created
- how to create both places and transitions, and what these terms mean
- how to customise your marking store, and why you might want too
- how to create your own workflow diagrams, and a potential bug you might encounter
Honestly I love the Workflow Component, and if you don’t already, hopefully after this series you will too.
Until next week, take care, and happy coding.