 Come on in and have a seat Hey, I'm Ben Turner. I am louder louder. Hey, I'm Ben Turner. I'm My day job is a support engineer at flywheel Before that I was and I started that maybe eight months ago before that I was doing a lot of freelance WordPress development and Just mucking around with the terminal and and all that sort of stuff I'm supposed to stay loud. Yes, sorry So if you want to Check out what I'm blogging about I occasionally post random obscure things at passions play comm You can also find me hit me up on github and We can geek out a bit, but so today I'm here to talk to you about using local by flywheel and so If you're here, you may or may not have heard about it But basically it's a tool for managing WordPress sites on your local machine And so if you're familiar with like MAMP or VVV or any of these other tools that help kind of Scaffold out a WordPress site on your local machine so you can break it and tinker with it and do development on it This is in that family of technology. So In a real basic sense, it has a nice GUI for creating sites. So, oh This is not right That'll be good. We'll size it down. Okay, so in terms of a GUI setup all you have to do is click the big plus button to Start the the creation It'll ask you a few questions like hey, what's what's the URL you want to use for this machine? How do you want to access it? Ask you different things like what kind of an environment do you want? So What version of PHP what you want to engine X or Apache? One last little sort of thing like what what's your WordPress admin user? How do you want that set up and once that's clicked through and done in like half a minute? Maybe less you got that nice little site with the green dot telling you that it's up. It's ready along with all this information about what you know what that site is and You can click that big button Visit site and you've got a plain vanilla WordPress site So within like half a minute you're up and running with a new sandbox to try out ideas Try out a plug-in try out a new theme Same vanilla WordPress dashboard So that's like creating something brand new blank from scratch, but they it also has this concept of a blueprint which Under the hood it's just like a database dump and a WP content folder with all the plugins but like if you're doing lots of WooCommerce sites you can you know Install WooCommerce handful of add-ons for it storefront theme and then say hey I want a blueprint of this and so you almost take a snapshot of it and then from here It's just a one one button click to scaffold out a new site with your sort of preferred sandbox of like This is what I develop in like I'm I do things with Divi theme or whatever So so that's kind of how local lets you scaffold up really quickly Once you go through do your dev work. You've you like what you have You know, you're not gonna keep your site on your local machine. So how do you get it out? Well, it's pretty pretty much just a right click and an export to again like dump the database zip it all up and All your plugins in the theme and then you can take it wherever so to another host You know, you can exclude certain files like all those large plugin backups you can just say I don't want those part of it and You know again like depending on the size of the site how much media you have It's done in like a minute just exporting and ready for you to Back it up like save that as a snapshot of you know, what are the project was at a certain time or Shoot it up somewhere else One thing I really like in terms of just like deployments if you do hosting with flywheel They they have that sort of built in so like in this case my my own blog is passions play and I have it connected to The passion's play site on flywheel servers so from here I can just pull down from the server or push up to Flywheel and it's kind of that same thing it'll export the database zip up the WP content Folder and fire it up to to the server You can optionally exclude the database so like if you're working on an e-commerce site You don't want to necessarily fire up all of your Fire up your database and overwrite those orders that have taken place while you were developing So that's that's a great way especially like in my day-to-day job where I'm Troubleshooting and firing up, you know a couple dozen sites every day I can just real quickly create a new site or import a site by just getting a zip and dragging and dropping and And just as importantly I can just delete it really quickly So these WordPress sites become really disposable and really quick to to work with But maybe you're here because you're on the developer track, right? And you're like I want terminal things and I know I initially Didn't think local was Gave me that much power to really interact with with these sites from like the from the command line Like I'm a I'm a pretty pretty geeky terminal guy and It's really easy to just fire it up and you can right-click open an SSH tunnel to it and You're basically inside the site container. So all the files are You know in your public in your app Slash public directory And you also have WPC li to interact with your WordPress site In that sort of fashion and I know you're thinking like okay cool But I already do that with man for a with VVV or whatever your flavor is or You know termux, maybe you're just firing up all of your sites that way One of the things that I think is cool though is that because the underlying Technology of local it uses Docker is that it's a neat way for you to start playing with containerization So, okay local Docker containers How many people have know about this stuff or? kind of Okay, so maybe maybe some people have heard it maybe even played with it. I'm gonna give like a quick rundown about it if you're new well, so so to rewind just a little bit like Looking at local more technically it basically is an electron app, which is like using HTML CSS and JavaScript as a desktop app And that electron app Coordinates different things different Docker containers And with the idea it's focused on WordPress, right? It's not It makes certain decisions where if it was working on a Drupal site It may not do certain other things or Magento would be whole different set of considerations So If we're gonna make this sort of an analogy Locals like a producer of a movie it doesn't do a lot of the actual hands-on dirty work But it it delegates the heavy lifting right so when when you say to local. Hey click that plus button I want to create a site it lines up everything to make it happen and and Continuing that analogy the WordPress is that star actor, right? So it's it needs everything that it needs to work correctly and to fire up So PHP my sequel That environment is Docker and Docker Manages those needs right it'll line up those different processes and encapsulate those in into individual environments And those environments are called containers Which are all managed and run within virtual box So if that's all kind of crazy crash course it might help to visualize How those interact and work with local so When you install local it shows up on your laptop Local will then install virtual box, which will then create a virtual machine on your on your laptop and Inside will install Docker. So that's kind of how those three main things interact But then on the day-to-day when we're clicking the create site It's creating a container Inside of which is WordPress and you can create at any number, you know, you're limited by basically the memory of your laptop So that's that's great, but how do we leverage that so Since local comes with Docker and and Docker machine, which is a command for kind of managing that virtual machine We can use those individual Vendor binaries to to interact with it through our terminals. So in this case, this is me on a Mac But I'm just aliasing Docker machine for the one that's located within the vendor directory You can always install Docker and just use that one But this is if you were wanting to kind of dive in and just get started Without having to install any other dependencies The only other caveat here is we basically have to tell Docker where we want to execute our commands And so in this case, we're setting up this terminal to be like hey Docker machine I want you to set up the environment to be using our local by flywheel virtual machine Which is that one that was created when virtual box was installed So what happens then is you can start inspecting those containers those little boxes of Wordpress sites, right? I Like piping Docker ps. So Docker ps is like list the processes list the Docker containers that are running I like piping that into less and Getting it so that you don't get these long lines that wrap around and cause weird Sort of flow issues, but as you can see here, like there's all these different Images right so this would be like a preferred environment which mimics flywheels Production servers, but there's also these custom ones where maybe I chose a different version of PHP or a different version of my sequel and The second command when kind of getting started with Docker is the inspect one so that that allows you to really say Okay, I know that there are all these containers, but but what are they right so if we were to look at this we can inspect this container ID and it's basically just a JSON blob of metadata and You can also inspect and format that output because it is JSON You can say well, I just want to know what the host config and the binds are what what the What folder is mounted to the app directory within the container And so with that you start being able to very powerfully script what you want to do and And and interact with the containers on a much larger scale as opposed to just interacting on one site at one time so so maybe Maybe that's a little abstract, right? So so one of the powerful things since this is WordPress is WPC li allows you to interact with WordPress in a very powerful command line way, so I just recently found out that WPC li has this dash SSH flag and one of those Protocols one of those schemes that you can use is Docker Docker compose or Vagrant even but you're basically saying I want to connect and run these WPC li commands on a remote machine in our case Those are those Docker containers, right? Those are quote-unquote remote even though they're on our local laptop. They're a remote instance So let's just kind of look at a Almost concrete a more concrete example, right? Like what if we wanted to list all the installed themes for all the sites that are running right now all those green dots, right? Well bash scripting is is here, right? If we were to break this problem down. We need to get a list of the running Running containers. We also need to do something with those so I Personally have been tinkering so I've got a bunch of other containers that are not WordPress containers running in that machine So using this filter flag I can say hey any any container that's published the port 3306 which is the default MySQL database port I Want to list those and that's just sort of a shorthand for Things that have a database running you can filter by all sorts of other parameters and stuff or using that format You know format flag to to get what you want But what we have here is just a basic list of each container ID that we want to work on so from there, it's just a matter of using that within a bash for loop and Echoing the container ID Getting the site URL as well as listing the theme and what ends up happening is you fire that off and you get a list That's really easy to be like. Oh, hey Look, I'm all up to date. This is awesome or oh, man I've got all these different vulnerabilities that I just read about on the word fence blog or whatever, right? For me, that's that's kind of where these scripting potential This scripting potential gets really powerful is I can operate on the whole suite of containers that And maybe it's a cluster of sites that are pretty similar, but I want to make sure I'm interacting with them in the kind of a batch kind of way That's I guess I'm pretty close on time and I can talk more about this sort of geeky stuff But I do want to open it up for maybe a question or two and If anyone has anything go for it Yeah Yeah Yeah, this is it's all on my github. There's a there's a link to a repo and I can also tweet out the URL but it's PP presentations Developer workflow With local I think is the repo name. So that's where all those notes are Yeah Yeah, I guess it kind of depends on so so it's Local isn't enforcing any sort of way that you need to do plugins I Guess for me, it's sort of a rule of thumb like how confident am I in these plugins if I've got a crap load of plugins that You know, I'm curious of the update I'll definitely pull them down and try updates and like in the case of this like maybe I know that there's a bunch of updates For one specific plug-in you can fire through and do Like instead of WP theme list you could go through and do like WP plug-in update All and just update all the plugins and then from there If you're hosted on flywheel push them up or if you're hosted somewhere else I don't know what that workflow would look like maybe It's more of a hassle to zip it up and fire it up, but Sort of depends on on how how you are deploying so Yeah Everybody has their own sort of way of doing things, right? So And a one else got a couple minutes left. Yeah I Don't typically use it for like remote docker management And like flywheel itself you're not interacting with containers or anything on their servers But I mean in theory these are all sandboxed little machines, so you could wrap them up and Isn't that what they say that's so amazing about dockers that you can Make it once and deploy anywhere so I think it's a really cool technology and Not least because it it allows a very isolated environment One other sort of use case that I've been using Well is that I'll create just a blank WordPress container and then use that as what I fire off the like plug-in unit tests and stuff within So I know that it's a completely sandboxed environment. There's no external Things happening and and it is really disposable, right? It's just a matter of Trashing that container and firing up another one So That's pretty much it Hit me up outside if you want to talk more or Yeah, so I think we're gonna have RJ up I think right