 Well good afternoon everybody. It's 310 so we're going to go ahead and get started. Thanks for sticking around for the the last talk in this room today, word camp Dayton. It's my first time here but kind of exploring the area. My brother's on Beaver Creek so I said to be here with you all in from Chicago. So to kind of wrap up here today we're gonna learn a little bit about modern tooling with WordPress if you couldn't have guessed from the slide in front of you. My name's Keenan. My parents blessed me with a very unique name both first and last so I get this handle on pretty much every social network. You can also email me which I check way too much and instead of like trying to write down every link and every name of everything you see in the talk I put up a page at alphaparticle.com slash WC Dayton with all the links to everything. So you can kind of go there and peruse the links to the slides are also there as well as word camp TV if and when that becomes available. So WordPress is turning 16 this year a couple other talks I mentioned that but it's been around for a while obviously very different from when it started but it's it's evolving as an ecosystem and as a community. So when WordPress kind of started out at least when I started working with WordPress most all of the options for hosting were your basic kind of shared hosting platforms where you got cPanel and you've got FTP access that was pretty much it. Initially WordPress didn't have great support for custom fields and things so if you wanted to do that you had to dig up the docs for add meta box and figure out how to do all the saving of your stuff custom. It was pretty tough because the stuff was on shared hosting to do like monitoring or figure out which parts your application were slow and kind of what was going on there and a lot of what WordPress started with was small to medium blocks. So now you know contrasting you kind of see that it's evolved into more of an application platform and really big websites are running on it. Some of these up here I hope there's at least one name up here you recognize. So all of these companies have web presences on the WordPress platform. So you know kind of thinking about how they might manage this process knowing they have a bunch of developers working on their platform it becomes easy to see that they're probably not drag-and-dropping files with FTP. So how has WordPress evolved to support these kind of large scale deployments and what can we learn from that to make our own work more efficient even if we're not working on big things like that. So these are all linked up on the page as well. Kind of some looks at this a different version of this talk that I've done a cloud scale WordPress talk put on by the folks at AWS. So pretty big name there talking about how you can deploy WordPress into the cloud if that's your game and also this talk. So if this is something you're just being learning about you're in the right spot if you're not then like we said earlier I won't be offended if you decide to leave. So the overarching theme of this talk as I was kind of going through it and putting it together as I realized that a lot of the stuff that kind of can take WordPress to the next level is taking actions that you would traditionally do in the admin setting up plugins or installing things or you know configuring custom fields and options like that and defining them in code. You could put code in quotes if you want to because it's kind of a different format in some cases. But this makes it really easy to keep track of what's going on across multiple environments. So if you're working on your local and then you're moving to a staging environment and you're moving to production like you don't have to recreate all the fields in the admin every time. It also makes it easier to work with multiple people because you can version control your entire project and then when someone new joins the team they can grab the repository and all of the kind of settings for various things are in there. So as you scale up WordPress like this configuration is code idea is a lot more important and so if that doesn't quite make sense yet we'll go through a bunch of examples but that's going to be key. So that's kind of the high level overview of everything we're going to go into. One more thing I want to say before we get started is like this I don't use all of these tools on every project. I wouldn't suggest that you do either and the idea is not for you to implement everything you see here but hopefully you have a specific problem either you know about already or you'll realize when you see one of these tools that might be able to help you out and you can pick just like one or two things and go implement those. That's the idea. So not to overwhelm you we're going to go through a lot of stuff but hopefully you kind of one or two things resonates with you and you can make see more efficient next project. So the first thing we're going to talk about is local environment. So I'm assuming mostly developers in the room how many of us are using a local environment developing on our computer somehow some way. Good, cool. This wasn't really a thing at least for me and the people I was working with when I started is pretty much again like we had our FTP target and we you know put files on there and made changes in there and made changes in the admin. But local environments are great because they let us work locally not on the live site and test things out and develop features over a longer period of time without having to worry that like we're breaking the experience on the live site or sites going to go down something like that. So the first option that technically is a local environment is you can just install PHP and my SQL kind of on your machine especially if you have a Mac that's really easy. I think it comes with PHP and maybe my SQL already installed. The problem with this is you know if you're working on multiple projects and one needs a different version of PHP or need to upgrade or something needs you know kind of gets off. That's your machine so you really have no option to just like destroy it and start over because that's your whole machine. So possible but I would not recommend it. So something that's become pretty popular in recent years is the idea of running a tool called vagrant inside a virtual box. So what this essentially does is it creates a virtual machine inside your computer and everything is self-contained in here. So what's great about this is you can install if you have a project that requires specific versions of things you can install just those specific versions in kind of this virtual machine. You can turn it on and off as you need to. You can have a bunch of them running side by side. Actually so we'll jump to this in a little bit but these so these are all the various like virtual machines that I have on my computer. So you know you see local by flyway which is a tool we'll talk about heads its own there for when I need to test stuff in an explorer I have a machine that I can turn on and off to do that and there's so there's just a bunch of various things that I do here but it's nice because it's self-contained and you can work with it specifically. Yeah so vagrant I believe works with virtual box and a couple others. VMware I believe it can do but yeah you can when you download it you can specify what you want to work with thought maybe be quick here but I think you I think you can do it oh yeah there's a link to VMware up here so yeah you can do it with VMware you just have to tell it when you when you look for your vagrant box that we want to do VMware. So what is vagrant exactly so it's a it's a virtual machine hooking into one of these virtual machine virtualization tools so virtual box or VMware or whatever with a specific configuration that's defined in what's called a vagrant file. So again this idea of configuration is code this vagrant file you say you know what base operating system do you want how much RAM do you want to give it from your machine what you know you can define all these things what what software do you want to install and basically then you have this self-contained environment you tell vagrant okay bring up this machine and it if it's the first time you're running it it goes and grabs all those resources for you and creates the virtual machine but then like I said you can just turn it on and off as you need to and once you've done the work of initially creating it and downloading everything you need it comes up pretty quick just like you know starting up your computer versus getting it from the store and installing the OS and all that stuff. So because it's its own separate machine you can get access into it and upgrade packages on it independently you can upgrade the whole box if you want it really is just like a machine inside your machine so we already talked about this a little bit kind of all the various ones that I have running so it kind of goes on a case-by-case basis homestead we'll talk about in a little bit but that's running like I don't know 10 or 15 sites on there and then some of these are just for individual specific projects so you can either have one machine that encompasses a whole lot of projects or if you just need you know one machine for one project like I said you can turn them on and off so they're not sucking up all the resources on your computer. So one good option that's targeted specifically toward WordPress is varying vagrant vagrants don't try to say that five times fast basically what it is is it's a wrapper around vagrant that lets you spin up and create you know WordPress sites much more easily so again it does configuration as kind of a code-based thing if we wanted to create a site for this conference we could just basically say okay we're going to create a site called Dayton we want the host to be Dayton.test you could do Dayton.local whatever you want it to be on your local machine and then it supports templates so basically this template is kind of they're getting started one it's a very basic one that just installs WordPress and a couple of their debugging plugins but basically you just specify this in your config tell vagrant okay I want to go run this and bring it up and then you have a WordPress site inside this kind of virtual environment so that's really great as opposed to you know having to go download all the WordPress core files and then you know put them in a folder and configure the database and then change your WP config and all that stuff it's really a lot quicker just to kind of bring that stuff up and it's all inside a virtual machine so if you do this and then you decide you don't need the site anymore you can delete it until vagrant to get rid of it or you can spin down the whole virtual machine and go from there. Homestead is another option it was built originally in the Laravel community so it's not it doesn't have as many WordPress specific options as VVV does but it's also based on vagrant so it's much the same idea it's a very similar syntax so in this case you have to tell it where so all of my various sites live in my code folder and on the virtual machine I want that to be in home vagrant code so then once that mapping of folders is set up you can just say okay I want a new site here and whenever somebody hits this URL it has to go look in this folder which is where all my WordPress code is going to be this is a much more manual process because I have to actually make sure that WordPress exists in that folder and that all my config is set up correctly but again if you work on stuff that's not just WordPress this is a good option because you know on this virtual machine I have WordPress and Laravel projects living side-by-side so it's kind of nice that way so then also the another option is Docker this is a question mark after because I'm not super familiar with Docker it's one of those things it's like sitting over here and I know I need to learn it eventually because it has some benefits over a virtual machine I'm just can't really quantify that so there's any Docker people here let's chat later because that'd be awesome but but 10 up a relatively large WordPress agency has a setup called WP local Docker which will get you up and running if Docker is your thing cool so we've got a local environment setup what are we gonna do about actually developing so we talked about some workflow things that were kind of clunky in the past with you know FTP and versioning and all that stuff and even just working on the site itself kind of how can we how can we put these things together so a big kink in the workflow of the past was if you wanted to install a plugin you either had to go through the admin or download a zip file and then drop it in your plugins folder activate it through the admin and stuff like that but in recent years there's a tool called Composer that's being used in PHP brought more broadly but specifically for WordPress there's a tool called W packages which is kind of a playoff of packages which is a composer repository for the bigger PHP community and what it allows you to do is every public plug-in on the WordPress plugin repository is mirrored here so if you're familiar with Composer and you know how to use that to manage PHP packages show of hands how many people is that by the way not too many okay so real quick Composer basically is again a tool that lets you specify one file and it says you can specify here's all of the packages that I need to run my software so before you start running something you can just say Composer install and it will go grab all of those different PHP libraries for you so you can run your code and again these are specified in a file so that if you check your code into version control you don't need to tell another developer oh make sure you install these five packages they just can get the file and then have Composer install everything for them so much in the same way WPAC just allows us to manage plugins in this exact same way so you can in your Composer file list out all of the plugins that your site needs to operate and then check that into version control so that when someone downloads all your code to start working on the project they can just run Composer install and it will take care of putting all the necessary plugins into the plugins folder so you don't really have to manage this then through you know an onboarding doc that says hey here's all the plugins you have to install or some of the other ways that people have done this in the past you can just let the tools help you and automatically install things for you so yeah seems like maybe not super useful for all of us here but if you use Composer already you're familiar with this if you experience the headaches involved with telling people which of the 20 plugins they need to run their local definitely look into this a little bit another thing is for a while there was kind of this common perception that plugins are basically just for you know functionality on the site or for end users but there's a lot of plugins that are specifically targeted towards people who are working on sites and building things so one of these is objects to objects in my opinion this is one of the times where if this is a requirement of what you're building WordPress maybe is not a super great choice for it but if you have to you can basically relate like the title says objects to objects so if you have posts and say galleries and you want to make sure certain galleries are related to certain posts and you want to have this connection so that on the post page you can display all the related galleries things like that objects can be anything so objects can be users objects can be custom posts types posts I believe even comments and things like that pages obviously so you can kind of make these connections and it makes it much easier to on the front end then display these objects that are related as opposed to having to you know go into wpdb or make direct database calls you that so this is a little small and this is mostly for the slides if you go download them online to see kind of how it sets up this connection but this is exactly what we were talking about earlier where we want to be able to relate galleries to a single post so just again this idea is like okay we're not defining this relationship anywhere in the admin or doing anything like that we're actually putting it in the code so this would either go in a plugin that we were building or or in a theme that says hey we know we're going to have this post type called galleries and we want to relate it to posts so that we can it then also gives you an admin interface for whoever's writing the content to make those relations and things like that so take a look at this online if you're interested but just know that that's there so field manager is another one i'm willing to bet a lot of us here have used advanced custom fields or something to that effect field manager is a similar situation where you can define custom fields and then have them magically show up in the admin but you know as we go through this and keep thinking about our common theme these are defined in code so while acf is is great and it has an awesome admin interface and lets you do all sorts of customization field manager actually lets you do this in code so once again it can be version controlled and it can be you don't have to you know recreate those same fields when you move between environments and things like that so acf does have kind of an export where you can generate all the code in the all the fields in the admin and then export it to code field manager just kind of skips that step and lets you write the code directly so not something that everyone's comfortable with if you rather would have that admin interface like that's great but if you're more working on a project with a bunch of people and want to make sure all your fields are version controlled things like that field manager is great and yes acf honorable mention we talked about kind of pros and cons of that so this is just how adding a group of fields would look with field manager so we just specify we have a group of fields in this case we'll just add you know contact information to a post for example we want a text field for name a text field for number and then a link to the author's website we'll say and then you see the last line there just add meta box contact information so it'll just add a box below the post that says you know here's the here's the field we want it handles all the things about saving them and sanitizing the input and stuff like that more details to come on how this works with Gutenberg but in the past with kind of the classic editor this was how it would set up the different meta boxes so if you need custom fields and you feel comfortable writing php this is a solid option for you query monitor i'm sure a lot of us have dealt with the situation where client calls up and says hey you know my page is taking five ten fifteen twenty seconds to load i once got that call in number was 60 seconds which is a whole fun different thing query monitor is a tool that sits right up in the top that that little black admin bar that everyone tries to hide query monitor sits up there on every page load and and if you have php notices php warnings php errors it will turn different colors to kind of alert you to the fact that hey something is going on but it also profiles things like database queries so if you have a particular section of your template that's making a really slow database query on it'll call that out in in bright red text for you it's super comprehensive in terms of what it will do the first time you use it you'll probably use it for one specific thing that it does and then for you'll use it for a different thing on a different project and i would not recommend trying to understand all of it at once um but if you have something that's kind of weirdly happening or you have a a check uh like your checking is single and that's not returning true when you expect it to be um it gives a lot of information into like what WordPress thinks it's loading what templates it thinks it's loading what database queries each component of the page is making uh and stuff like that so if you do a lot of work with inheriting projects that you then need to upgrade or fix and things like that this is great um query monitor would definitely recommend checking it out um and yes you'll have to unhide the admin bar for it to be pretty useful while you're working on the site rewrites are another area of WordPress that's kind of a black box in a lot of ways um who's worked on like doing custom rewrite stuff here before a couple people yeah um so it's more of that regex fun that Steve was talking about before um and it's really finicky