Open Source Contributor for Pantheon, Greg Anderson, takes us through Drush 9 and what that means for your existing plugins, as well as tips for rescuing your family from the internet.

You might say Drush 9 was born from fire, but that was because we upgraded from Symfony 2 to Symfony 3.  Aside from rewriting Drush, Greg teaches people to dance as an improv performer at the Great Dickens Christmas Fair.

He also shares some excellent tips for getting started on your first drush plugin, and how to get in the routine of cutting the internet cord every night.

This Episode's Guest

Greg Anderson

Thumbnail

Greg Anderson is an Open Source Contributor working directly on Drupal, Wordpress, and development tools such as Drush.

Transcript

Transcript

Chris Albrecht:
We're here at BADCamp, we're going behind the screens with Greg Anderson from Pantheon. Hi, Greg.
Greg Anderson:
Hey, how are you?
Chris Albrecht:
I'm good. How are you doing?
Greg Anderson:
Great.
Chris Albrecht:
What do you have going on at Pantheon these days? What are you working on?
Greg Anderson:
Actually, right now I'm spending a lot of time preparing for the RC1 release of Drush 9 and I'm very fortunate that Pantheon sponsors a lot of my time to give back to the community. My title at Pantheon is Open Source Contributor. I'm also on the Platform Structure team, which means I spend a lot of time working on the back end of the system. But recently there was this little thing called Drupal 8.4.0 that came out and someone had the great idea and says, "Hey, I know what I should do! I should start using Symfony 3 because Symfony 3's better than Symfony 2."
 
They did this in core and it mostly worked in Drush, but we started noticing we're using Drush. We thought we smelled something, it smelt like something was burning. We looked behind Drush and there was a thin little bit of smoke coming up the back. We looked a little bit more closely and it's like, "Oh my god, Drush is on fire! It's Symfony 3, Symfony 3 set Drush on fire!" So this was a little bit before Vienna. We looked into all of the different things we could do, we're like, "You know, the old Drush is, it's been around for 11 years and it's got a lot of technical debt. The Symfony 3 thing, it's really kind of getting us down. I know what we should do, we should rewrite the entire Drush runtime to use Symfony console." So that's what we did.
 
We just took out the runtime that was there before. We've been planning this for a long time and Moshe had already rewritten all of the commands in this new adapter layer that was ready to have Symfony counsel inserted in underneath. But, once we dropped out our old runtime, a lot of these commands were still relying on stuff that was dependent on the old runtime. So we had a lot of refactoring to do. But it felt really good to do it because the old Drush would have these really long 2500 line files of site alias.inc of just individual functions that don't really vaguely relate to each other. One functional area would call another functional area that wasn't really supposed to. Now we've got all of that stuff rewritten and classes and wired together with dependency injection. It all came together pretty nicely because we built it on top of Robo, which is a task runner for PHP that's written on top of Symfony console. It has capabilities like configuration and yaml files and annotations for making hooks and various things like that.
 
It was a phenomenal success. There was a period of time where I felt like at Vienna we were either going to have slides or working code by the time that we got on stage, and not both. But somehow it came to pass that we had both slides and working code and we had a really strong beta to show to people. So far we've had pretty good feedback from the community. We've had a lot of people porting the old Drush commands to the new format because the new Drush doesn't recognize the old Drush commands. We did think about doing a compatibility layer, but the old Drush was just a huge ... There was no API per se, their API was any function in Drush. So we couldn't really predict who was going to call what. We would have had to take all of that stuff along and I just want to get rid of it.
 
So, clean break in Drush 9 and we're still working ... We announced that we were hoping to do an RC1 around BADCamp time. It kind of looks like we're converging, but that's likely to happen. We didn't get it done just before BADCamp, but maybe a week or two after BADCamp. After that we're not planning on doing RCs for a year. We're going to maybe just let it bake for a couple of weeks and hopefully we'll have a 900 stable out soon.
Chris Albrecht:
Excellent. So by the time that this episode goes live it's very likely that there will be an RC1 out ready to go for Drush 9?
Greg Anderson:
Yeah, entirely likely. We'll keep our fingers crossed and see how it goes. We're down to just a few commands and then of course we have all of our aspirational goals. So at a certain point in time we just have to draw the line in the sand and say, okay this is stable we're going to live with it. I wrote a blog a couple of years ago, Don't Fear the 1.0, you should Google it. Because sometimes you get this fear of completion. It's like, oh you know, if I label it stable then I have to maintain backwards compatibility and I'm not ready for that. I can't be ready for that. Sometimes people, I've seen projects do an entire new stable release. They'll just take a year to get to stable and what they should have done is drawn the line in the sand said, we're stable here. Then they can always make another fine release over the next six to twelve to eighteen months is a good period of time for something big like Drush that a lot of people use.
 
We don't like to do a stable release more than every year or so. But, in our experience a year goes by really quickly-
Chris Albrecht:
Yeah, I bet.
Greg Anderson:
So, it takes a while to have the master branch evolve to the state where it can go stable. So we don't worry that much about committing to the backwards compatibility because it's going to take us a long time to build whatever the next thing is. We're really looking forward, now that we have the object oriented Drush and there's a well defined API and a path forward, that people aren't going to have to keep writing their commands over again. We should be able to continue to maintain that as time goes forward.
Chris Albrecht:
Excellent. So if I have Drush commands that I've written for my own project to help with deployments or projects specific things and it's been working great up through Drush 8, I'm going to need to rewrite those if I want to use Drush 9 now?
Greg Anderson:
Yeah, that's right. But we've got a generator and the generator will look at the command that you already wrote and then it will scaffold up a new command file and it will have all of your old commands defined. They'll just have an empty implantation. So then you just have to go back and copy the implantation over and find your old Drush get options and convert that to a more modern API. We'll start blogging about that and people have already started doing it. So we're going to have more and more examples in the community of it you can go and peek at if you want to do it.
 
So really, your commands are going to be the easy part. The harder part is if you have a site and it has a lot of contrite modules that have a lot of Drush commands in them, then in that case you're probably going to want to stick with Drush 8 for a little while until all of those can get ported by the community. Or if you're really motivated, you could help port them yourself because it's not that hard to do. But there's only a few score Drush commands for Drupal 8.
Chris Albrecht:
Mm-hmm (affirmative). Excellent, that's exciting. I can't wait to get into that. It's one of the things ... I do write a lot of Drush commands for myself, and I have a few plugins that I've shared back to the community, but I've always wanted to have it be more object oriented from the core-
Greg Anderson:
Right.
Chris Albrecht:
There are pieces in there that rely on that, but I'm very excited now that you've gone through and given it a complete rewrite and brought it up into that modern framework-
Greg Anderson:
Yeah-
Chris Albrecht:
So that's very exciting to see. I'll keep an eye out for that and we'll put links into the show notes about the article that you wrote and the progress of the project. So if somebody wanted to jump in and help with some of the porting or working on some testing, where would they go?
Greg Anderson:
Oh yeah, we always encourage people to participate and if they have something in mind already they can just submit a PR right into the GetHubba project. We always are happy to see people contributing in that way. If people are more, I'm not sure how this is working yet, but I would like to learn and contribute, we've got a Drush channel on Slack so you can just pop in there and we'll see it. There's also a Drush channel on IRC. I personally, I'm not there very often because my IRC client are used with the rest of my operating system. I don't keep it running very often, but I think Moshe is there a lot.
 
Then of course, we're both on Twitter so if you just #Drush or @-mention DrushCLI then we'll see that too. There's lots of ways you can get in touch with us and we're really always willing to help people come up to speed on this stuff.
Chris Albrecht:
Fantastic. So if you could give a piece of advice to somebody who's wanting to maybe start writing Drush commands, they really enjoy the tool and they want to get in and participate in it, what's one thing you would suggest to somebody to start off with?
Greg Anderson:
I'd just look at what's already there. I mean, that's a great piece of advice, no matter what you're doing. Even way back in the Macintosh days when I first started doing this stuff, people were saying, oh no one really remembers how to write a Macintosh application, they just take an application that was already written and they copy it and then they change the inside so it does what they want. That's a basic tried and true technique that's not going to outgrow us no matter how many different times we change our domain.
Chris Albrecht:
Right. Very cool. That's great advice. That's, I think, how I wrote my first Drush command is I took something else and copied, paste, rewrite the logic, change the name and there you go.
Greg Anderson:
It's the best way.
Chris Albrecht:
Very nice. So, we can take this and flip it over now a little bit. We've been talking a lot about work and what you've been working on. But what would happen, what would you do, if you woke up tomorrow and, let's just say, the internet disappeared.
Greg Anderson:
I'm actually very well positioned for this scenario. Because when I'm not working on the internet, I actually spend a lot of time in historic recreation societies. This is actually coming up, is my 16th season as an improve performer at the Great Dickens Christmas Fair. Where we dress up in Victorian clothing and basically what we do, not the whole fair, but our particular role in the fair is we teach people how to dance. We dance the waltz and we dance the [inaudible 00:10:40] and their english country dances. So certainly dancing would be a fun way to spend my time. But if I needed to do something a little bit more practical perhaps some steam punk bavage engine might satisfy my technical urges without actually needing an actual computer.
 
If that was too difficult I could always go back a few hundred years because I also participate in something called The Society for Creative Anachronism where we dress up in medieval time clothing and really reenact the middle ages. Arts and crafts are really big there. So there's a lot of things that I've wanted to do in the SC that I just haven't had time for. In fact, you might not believe this off the top of ... On face value, but blacksmithing is really fun. You just have a really heavy hammer and you hit a piece of hot metal over and over again and if it turns into some awful twisted shape because you're a terrible blacksmither, as I currently am, it's still terribly fun. I would like to be able to do this enough times that I could make something that didn't look like a terribly twisted sheet of metal.
 
So I would be actually fairly happy if I had the excuse of not having an internet anywhere. In fact, for our son, we sometimes do this. We turn the internet completely off so he has to forget about it. Because sometimes it's a struggle in his brain to pull himself away from the video games and pull himself away from the internet. But if it's actually off, then he disengages and he's back in the real world. It's one of the reasons we do SCI, we drag him out in the woods. We have camping events and there's literally no internet. We have to go to these classes where we learn how to do arts and crafty kind of things.
 
So that's what I would do.
Chris Albrecht:
That's amazing, oh my gosh, that's such a great idea. I love that, just turn the internet off and have an internet free, tech free night. Those are some fantastic ... I'm a little scared that you're ready to go right away. We kind of need you to hang around for a little while, Greg. But that sounds like-
Greg Anderson:
Maybe I could come back and visit the internet every now and then. But we actually practice that every single day. We have a little light timer plugged into the wall, and our internet router and the switch are plugged into that. At 9:40 PM, the internet switches off for the whole family, adults and kids don't use the internet and we get ready for bed and we go to sleep. So now we don't have this glowing screen in front of our eyes keeping ourselves awake. We know the internet is going to come back on in the morning when we wake up. So we go to bed on time, we wake up early, and we're ready to go.
Chris Albrecht:
I really like that idea. I might steal that and take that home with me.
Greg Anderson:
I think all of your listeners should just try this for a while because it's really amazingly great. Sometimes it's frustrating when you're trying to finish something and you see the time is going towards 9:40, but you know you get used to it. You know the internet is going to come back in the morning. It really makes for a more relaxing evening.
Chris Albrecht:
I bet. Wow, that's a great idea. All right well we're going to do two more questions. First will be, is there ... I always that we all got here with a little help from somebody else. The community is always there to support us, can you think of somebody you'd like to say thank you to or share some gratitude with me that gave you a boost when you needed it?
Greg Anderson:
Oh yeah, definitely I'd like to thank Moshe Weitzman because he pretty much ushered me into this whole Drupal community. I came into Drupal through Drush and I just started contributing on the queue and Moshe was super welcoming and really taught me a lot about Drush. By looking at how Drush commands were implemented and that's how I learned about the Drupal API. I wanted to do something in Drupal I'd go like, oh I know how to do that in Drush. There's a Drush command for that. Look at the code and I'd be up and going and he's always been super helpful to help me work through hard spots. Just be there as a mentor at Drupal Con and provide encouragement for keeping this crazy tool we've both been working on for so many years alive and kicking.
Chris Albrecht:
That's excellent. I'd like to say thank you to him too for helping you out because I now rely so heavily on this tool for so much of my workflow day to day, so I'm glad that you're able to put that work in and that you've got somebody like that as a good mentor to help you along the way.
 
Greg thanks for taking a few minutes to talk with us today. This is great.
Greg Anderson:
Yeah, thank you. I appreciate it.

If you enjoyed this Episode, you may also enjoy...

About host Chris Albrecht

Chris Albrecht
His backend brings all the nerds to the code. Skilled in Drupal development and architecture, you can often find him running through the Colorado wilderness and hosting the Behind the Screens podcast.