 Wel, mae'r ddechrau eich gweld. Hei, am ychydig. Efallai yma wedi gwrs y Dweud Fawr. Mae'r dweud, maen nhw'n gweld i'r ysgol. Mae'n amlion Cairngray. Roeddwn i'n dweud y Maen nhw'n gweld i'r dweud yn y Viga. Mae'n iawn. Roeddwn i'n gweld i dweud i'r Dweud Fawr, i'r 7 lle. If you follow me on LinkedIn, you will know that I'm a professional cat holder, and if you follow me on Twitter, you know I'm a little bit of a newsman. So that's my introduction. So, what is Drupal console? Basically it is a bunch of tools about a driven-in to my online, which lets you generate all-of-hate code and then lets you interact with your Drupal 8 installation. So it can help you do things like rebuilding the caches, working with configuration management, creating new modules. So you might think to yourself, well what about Drush? Well, Drush has been around for a very long time. It's been around since Drupal 4.7. Drush has a lot more features, but it works on old design concepts. Whereas Drupal console, it's been written for Drupal 8, so it uses the modern practices that Drupal 8 uses, simply components, and it uses like the new design practices. And the good thing about it is it has a bunch of new features to make your life a-duplate that little bit better for you. So what I've done for this talk is I've installed a local version of Drupal using Drupal VM on my machine. So the first thing I'm going to do is I'm going to install Drupal using Drupal console. So using the command drupal-citing-stool. I have luckily pre-recorded everything I've done, so there's no live demos here. So put in the command. Wait for it to kick in a little bit. It will ask you what installation you want to use. So I'm using the standard one. You can ask what language, what kind of database you want to use. Put in your database details based on what we just used for Drupal VM, which is the standard Drupal-Drupal. Can you turn the resolution up? Because it's not really readable. I wouldn't have a clue how. It's just plugged in. It's done through VGA, so I'm not sure. I am one of these. Oh, right. It's different. Can you go to the display settings? I'm a bit fuzzy, that's the problem. What you're showing is all CLI, isn't it? So if you go to the actual window, the Mac display settings. Displays. So go to hit-scaled. What's that look like now? Option, yeah, hit-option. Which is... Is that command all the one next to it? Yeah, so hit-option now. Hit-scaled. Where is it? Where it says the scaled button. It is on there. Yeah. Yeah, it's not doing it. It's got this... What happens if you just put the radio button on the scale? That's the radio button on the scale. It's on there. No, no, it's on-scaled, on here. Yeah, gather with... You didn't like it. No. That's... It's gone back. Yeah, I think you have to change the resolution. This man knows he's got experience. Let's pull the brightness up as much as you can. No, no, it won't be an RGB issue. It's a resolution issue. Sorry, I think we're just going to... What we were shown this morning is that we have to set it to scale, and then you have to set it to a different resolution to make it work. Well, were you here then this morning? Yeah. And that's what's not happening. So we need to go into settings and display. I think there is going to be a difference. Yeah, it's... They need to be able to see what you've got on screen, don't they? Yeah. So we need it clearer than that. Does that make sense? Or would you run with what you've got? We haven't got a lot of choice, have we? Yeah, we can... It's video. This one, you're explaining it? Yeah, exactly. Right, so it's out here. Right, so I'll let all this go for again. So it's installing. It's installing Drupal for you. So it goes for a bunch of questions. So you set, like, the standard installation, using MySQL well for this. Put in your database details. Do you ask the camera and have issues? Oh, Alex. It's just really fuzzy. You've got to turn it off and on, that's it. Is that it? It's really fuzzy. It's just fuzzy. Fine, alright. I'll go set my DJ booth up. Right, so once you've gone through the questions, it goes through and starts building your Drupal installation for you. So this takes about 40 discussions. So what I can quickly talk to you about is that it has all default settings in the yellow bit. So if you're happy with those information, you can just press Enter and it will use that default information for you. It looks like some DIY app is actually working. Yeah, almost. Right, so it's done. So if we go to the browser and check the website, there it is. It's installed. So what we can do now is we can create a new custom module. So using the Drupal generate module command, we can create any custom module for you. So when it kicks in, it will ask you what you want to call your module. So for my example, I'm going to call it Cats. So you can keep the machine name or you can prefix it. So I think I've prefix it within Vika. I'm keeping the default path of modules custom. You can put in any description you like, so I'll put in my awesome module about Cats. You can set a custom package name, so I'm keeping to my prefix within Vika. The same call version. I've said yes to a module file because I'll be using this later. I don't want it as a feature, so I've kept it to no. I don't need a composer-jason file for this example, so again, I've selected no. I don't need any dependencies. I don't want to do any unit testing and I don't want it translationable. So all of these I can just say no to. When you confirm a generation where it's those created two files for you, so it's created the YAML file, the info, and a module file for you. So when I started working with Drupal 8, it massively daunting for me to begin with going from Drupal 7 to Drupal 8 because the way you create a custom module is completely different. You've got always brand new files, always YAML files. It gets a little bit confusing and a little bit daunting, so doing something like this takes away that pressure from you and it does it for you, which is fantastic. So if we go to our module page, we can see there's our new module right there, so it's worked perfectly. So the next thing I want to do is I want to create a content entity for this module. So we're using the Drupal Generate entity content function. So what I want to do with my custom module is I want to create an FAQ for it and I want to have it attached to a different content type. So that's what I'm going to do here. So we use the module we've just created. The class, I'm going to call it FAQ. The machine is fine. And the label, I'm just going to capitalise it. The base path is fine, we'll keep that as is. I don't want it to be a bundle, so I've kept it to no. I don't need it translatable, so I've said no. I don't want it to be reasonable. And it's created all these files for you. So that's quite a lot of files. So you probably might be able to do that. But briefly explaining what it's done. It's created a tube template for you. It's created the form settings pages for you. It's created access control candlers for you. It's created permission files, it's created links. So all of that work, it's done it all for you so you don't have to worry about it. And the good thing about this, this is boilerplate code. So there's things in here you don't need. You can just whip them out, you can put things in. So we'll cover that in a little bit. Did you have to move them to your cat's sub-directory for my direction before we did that? No. Was it first thing? It's all done in dot group. So if we go to the sense page we just created, you can see here FAQ settings. And because it's a content entity, we can create fields for this entity. So I've gone a little bit ahead and I've gone and created a body field. Because you don't want to see me creating content too slow. So if we go to manage fields, I've created a body thing in here. So the next thing I want to do, is I want to attach this FAQ to a content type. So I'm going to attach it to the article. We use that using entity reference. So I've already created it here. And if I go to edit it and I just demonstrate that in the field settings but I've selected the FAQ as the item of reference that we're going to be using. So next, what I'm going to do is I'm going to create some content. So if I add content and go to article, put in a title for cat's FAQ. That's what we're going to be creating. If we go down to the bottom, there's our content entity. So use the name for the question. So I put in how many lives do cats have? And my answer will be nine fluffy lives. So we go ahead and save this. And there's our content. So we can see the entity title and the body field that we created. That looks a little bit plain. So I've added some CSS. And there we go. We've got something about resembles and FAQ. So what can we improve on this? So the Dupal console is boilerplate code. So everything that it generates for you, you don't have to keep that. You can put stuff in. You can take stuff out. So one thing that I did notice is that content entities comes with a published status by default. I don't need this because I'm not defining if this is published or unpublished. It just seems like code that I don't need. So I'm going to flip it out. So there's several places that this exists. So in the FAQ interface file, you've got isPublish and another one is deleted. So I've got a bit of them. And then the fields themselves in the class PHP, they can just go. The next place is in the access control handler. So we've got an if statement in there to check if the content is published or not. I don't need this. But I do need to have it viewable. But I don't need the published part. So I'll just take out the part that says published and I just have a view FAQ entities. And then in the permissions handle, I take out the unpublished one and just rename the published one to say view FAQ entities. So I need to check that I haven't just bugged everything up. So I've got to clear the cache. I did treat, cheat and use Drush because it's a little bit quicker. So that's cleared. And if I refresh the page, it's still there. So I haven't messed up any sort of viewing FAQ entities for this content. So the next thing we can do is we can create some dummy content for this. So this is very handy for QA environments where they need to test your environment and test what you've built. Before, you would use develop for this. But with Drupal console, you don't need it anymore. You can just run Drupal create notes. So if you run a function, it'll ask you what content type you want to create. So select an article. It'll say how many you want to create. So I'm just making five, nice and easy to title. Keep that to five. Set it to now. You can set it in the past if you need to. And it's created all the content. So if I go to my content overview, there's all my created content. And if I click on one of these, you'll be able to see all the content that's been generated for it. And at the bottom is some new FAQs. Now I did cheat a little bit and I did create some FAQs beforehand because that function will reference existing FAQ entities. So again, that's something that could be improved on in the future where you can tell it to create new ones for you, which would really help for QA instances. Now before, I created a body field. And that was just in the UI. So I need to export this information back into our codebase. So we can export this using configuration management. So we've got three-fold config export. So this is a nice simple function. You just run it and wherever you set the directory to export the configuration, it'll just pop it in there for you. So I'll quickly show you where it is in my directory. So there it is outside my Docker in config. There's my entire site configuration. Now we should really test if it's actually picked it up and it works. So I'm just going to make a nice quick change like changing the email address of the site. So I'll change it from Karen to Katz. And then we should check this in the configuration management to see if it's actually picked it up. And there it is. You can see the change between Karen and Katz. So just a row of you what I've discovered. So you can install your Dupal site using Dupal site install. You can create your own custom module using Dupal generate module. You can create your own entity contents using Dupal generate entity content. Create some dummy nodes and you can export your configuration. The Dupal console documentation is really good if you need to cover any of it. You can go to Dupal console.com or that ridiculously long URL to go to the page which shows you all the different functions that there are. There's a 152 command so far. So go ahead and go use it and go create something amazing. So I'm a professional catherder if you heard it at the beginning but it always leaves us an example to use. So if they don't see your cats then? Me. Is it compatible with them? It could be. So you can just create a custom entity by the module. Yes. So you can create entities and you can create custom content entities as well. So during the content entity you can ask if you want it to be a bundle or not so you can make it an actual content type if you like. But for my example I went to the article because it already existed. Your welcome slide. That one or that one? That's the one. The project I've just done at work the one I used the most was the content entities one so that's the one I featured because I had to create an FAQ funnily enough and other different types so I thought that was the best one to show because that was the one that impressed me the most when I used Dupal console before and I was like this is actually pretty handy I could do a talk about this. So that's what came from. I mean you could do, I mean you can clear up Drush with Dupal console I just found it a little bit too slow for this demonstration but it does it just as well. Does console do anything like syncing sites or I don't think that space is any of that stuff that I used to push a lot for? Well, you don't know. Is console easy to update like I installed it a year ago and tend to not touch it? I got it installed when I did my Dupal BM so it was part of that but I can't see a reason why it wouldn't be easy to update. So you just do compose the update and it should just pick it up. Is it extensible? I think so. I can't see why not. Does that have something similar to age Drush? Agus is so it might need to remote sites and that sort of thing? I don't know but I can certainly check and let you know. How important do you think it is that you understand what it's doing? Some important? I mean I'm a back end developer so I do quite understand what it's doing and you don't really understand the whole jargon of what it's doing. It's good for that because sometimes you don't need to know what it's doing and you can leave the code as it is. You don't have to play around but you don't have to rip functions out like I do. I just did it because if there's code there you don't need what's in there. I know you can download them and you can use like but mainly for Dupal late if you're using the other composer, Jason I think that's probably the best place to update your modules. I'm not using the VIA installing console as someone mentioned about composer I know it's pretty good. Just installing console just to make it available for quite a bit. I just did it recently I've not used it yet so I just go around and just do the composer so I just do the composer and then just link to my binary Drupal file in the path in the new European and that's it. You can install it globally so it will work throughout everything but for this instance I just I thought it would get Drupal VM and it was part of one of the requirements I told it to get a Drupal console for me and it did. Just to answer somebody else's question you can use Scrush in your solution. There you go. OK, so we've finished quite early it's 20 to 5 so everyone can go to the pub early. Thank you!