 Okay, good morning, and welcome to Drupal Connola 2016 in New Orleans, U.S. This is the Drupal 8 Kickstart presentation and overview for developers. My name is Peter Salfchenetz, and I'm a senior customer success engineer at Pantheon, and Pantheon is a website management platform, especially thoroughbred design for Drupal and WordPress. I have an opportunity at this time to work with some giants in the industry here at Pantheon, and fortunately, in my previous positions, I've also had that same opportunity. I started at about a year ago looking into Drupal 8, and as I was doing it, I decided I might as well catalog like what I'm doing and document it, and then I turned it into a slideshow, and then I sent it out for a couple of proposals, and it got picked up at a whole bunch of Drupal camps, including Bad Camp, and then it was accepted here at Drupal Connola, so that's very nice. So what I wanted to preface it with is I move really fast through a lot of information. I believe I have 75 slides, but I assure you everyone will come away knowing something that they didn't when they started, and I believe that you will pick up a lot of things like I did along the way. So I start out by looking at some essential reading, and the Drupal 8 API reference online on Drupal.org I would like to tell you is just an excellent reference. So if you're already quite a good Drupal 7 developer, but you haven't really looked at Drupal 8 yet, if you were to read the Drupal 8 API documentation from top to bottom and follow a couple of links, you know, deeper in as you go through each of the sections, you will come away with a really good picture of what you need to know for Drupal 8. So I highly advise looking at that at this time. The programmers guide to Drupal from O'Reilly is extra interesting because it has D7 and D8 examples side by side showing you how things were done in D7 and how they're being done in D8, and if that could be good for you, it's an invaluable reference in that way. Online documentation, there is a lot. A lot of it is out of date. You know, Drupal is changing so fast through the alphas and the betas, and by the time it got formally released that I would... I'm comfortable saying anything older than December 2015 is probably not fully correct, and you may not even notice what could be wrong with it or what issues the documentation might have until later you try to do something. So that's why the Drupal 8 documentation on Drupal.org is really, really invaluable because it's very current, and so if you do read around online, just keep an eye out on currency that things are current. So an interesting thing about Drupal 8, this is a bunch of... From my experience working on enterprise websites, this is the kind of products, tools, libraries, or things that I've had to be conversant in, be able to configure, or be able to use in relationship to Drupal 7 and Drupal 8. And so everything in this slide presentation is uploaded to the description of the session on the DrupalCon website, and everything that you see that looks like a link is linked to a very good resource that will tell you about this topic. So this is the only time we're going to look at something with this much hectic information in it, but like I'm saying, if there's anything in here that you haven't really read up on or that you're not conversant on, knowing something about everything on this page will make you a more valuable adjunct in your business environment. So this is the basic concept of Drupal 8, was to finally successfully separate data from presentation, and they have to great end achieve that in core, and most of the best contrib modules achieve that too. And you may have heard of headless Drupal, and all that headless Drupal means is you could use Drupal as up to that dotted line, which is only returning data, and you don't have any formatting in it at all. So that's the headless Drupal concept. So that's some Node.js application somewhere, or some other website with an API, could be calling into your website and only getting data back from Drupal. No presentation at all, no theme layer in use. So that's headless Drupal. But subsequently, when we get past the data, we want all the formatting to go on, where you're going to return the format that was requested, and coming from the other way is the request, you know, coming in. So from Drupal 8's perspective, and what they would hope you would design into your own module work as you go along, is this same standard. Return data and then turn it into render arrays and format it in Twig, but do not return HTML mixed with some data, no matter what, no matter how little, no matter how major, no matter how complicated, try to do that. And then this way, in the future, whether you get an API call for your page, or whether you get a browser call, whether you get it from mobile or the desktop, you're prepared because you can respond correctly in every way. The idea also was to leverage existing industry standard technologies, recognized PHP frameworks using PHP object-oriented concepts. And so to this end, Drupal 8 is built on top of Symphony. And it's just a side note that at some point, Drupal 8, they're currently using Symphony 2.7. At some point, they plan to upgrade to Symphony 3. And so if in your module, you're actually programming to Symphony, which you would be entitled to do, you should not program towards anything in Symphony that might get deprecated going into Symphony 3. So some D8 essentials. This is, again, from my sort of hard-won experience. This is, again, concept software tools that you... advisedly you should be familiar with if you're going to look at Drupal 8. So you have Composer, Drush, the Drupal console, Git and GitHub, YAML files, object-oriented and PHP, comments and annotations, and getting more comfortable with testing if you haven't been doing testing. And so I've written a lot of Behat. I haven't written any PHP unit, but I've written a lot of Behat. And I can tell you, yeah, it is a bit of a grind, but it does save you. When you finally make a change in the website and it breaks something over there that you didn't anticipate, you run your Behat tests, and so your Behat test breaks. You push something new, you run your tests, and you don't need people. You don't need, like, the team testing pages. So I'm just going to step through some of these items. So Composer is a dependency manager or a package manager relatively newer in PHP for pulling down the libraries and the tools that you need inside your website. So Drupal 8 can actually use that. And when you install Drupal 8 today, after you download it and install it, you have to actually go into the doc root directory and run Composer install. And Composer install is actually going to pull down Symphony and about 10 or 12 other related libraries into your Drupal site into the vendor folder. And then that's where you're going to have all of your adjunct libraries resident in the future and your advice to put yours there too so that it's all centralized like that. And so Composer uses JSON files that have names of libraries or tools that you want to download with the version that you would like to get and maybe some other information. And when you say Composer install it goes into that JSON file it grabs everything you said that you wanted goes out to the repositories pulls everything in and installs it for you. So that's what Composer does and if you haven't looked at it or used it I can highly recommend it. So and over here just to show an example that directory there called resources but it could also be vendor you can see that has like 15 PHP libraries and adjuncts that have been pulled in to support a single website. So if you were downloading all of these on your own you know you would be going and installing them and configuring them. With Composer you get that one JSON file together and you just pull all of this down with one command called Composer install. Later if you want to stay current with every one of these libraries like you're not concerned about being locked into a certain old version you can just run Composer update it'll go out, it'll look at every repository and it'll go wow there's a new version pull it down for you. You can say pull down dev even I'm so I want to say so on the edge that you can pull down dev versions for me if they're there. Or on the other hand in your JSON lock file you can go in and say do not update this particular library beyond this version and when you do Composer update it'll leave those for you and it'll only update the ones you have not indicated so. So Composer manager is a Drupal 8 module that allows you to actually make these kind of updates through the Drupal 8 admin interface. And so you can look this up and download it and install it and it gives you a very nice graphical admin interface and I highly recommend looking at it. Drush, I'm going to assume everybody in here uses Drush like a good team but if not you should start using Drush immediately I estimate from my experience again that it will increase your Drupal admin time by three to ten times over going into the admin to do things. I used to have a big page of example Drush commands but take it from me if you haven't used Drush you can login, you can make users delete users, you can create features update features install modules, uninstall modules run ad hoc SQL queries against the database everything through Drush and it's really excellent and you can install Drush using Composer very nice. The Drupal console this is an item that some people are saying wow this is a lot like Drush why do they both exist but Drupal console actually is another app you download it you can install it individually into every Drupal website you have or you can install it globally for your entire work environment but in Drupal console you can go make me a brand new module scaffold and it will create a big blank Drupal 8 module scaffold with all the correct YAML files in place the directory structure pre-built for you sample class files started up for you it's really brilliant I highly recommend you download and get comfortable with this tool immediately for Drupal 8 and on top of that it can introspect your website showing you every route that is inside your website and every module that is handling that route and it can show you many other configurations about Drupal 8 and it can execute some admin tasks for you and then again a bunch of good links on how to use it version control of some kind if not these are the tools to look at GitHub and BitBucket and there's actually a next level Git session that you could still attend here at Drupal if you want to just jump deep into Git immediately YAML files so all the configuration that Drupal used to hide in the database which actually it technically still does but now it puts them and I'll explain now puts them into YAML files and YAML is a recursive acronym for YAML Ain't Markup Language basically YAML looks like JSON so what happens now is when you make a module and you want to have some default settings for your module on the admin page you're going to have those in a YAML file and when you enable your module Drupal is going to go in there and if you have default settings it will read them out and it will put them in the database for you so a couple of interesting things about it is that it is case sensitive and you should use two spaces when you're indenting and you should not use tabs there are other frameworks where the standard for YAML files is four spaces to create indenting but in Drupal it is two and you can even make schema files for your YAML files like you can do with XML so this is what a sample YAML file looks like this is actually the core services and so basically if we skip that top part with parameters and we go to services it is defining services that are available in Drupal and so that first one is called cache context by IP and then it notes the class that handles this particular service arguments that it accepts by default when it is instantiated and tags is like the group that it belongs to within Drupal so we're just going to quick look at classes so classes is a group of methods and properties organized in a file that offer a service or do something so how I explain this concept for people who are new to OOP is that you know in PHP you have include and require and that's how you bring in extra technology from other PHP files in classes instead of having include and require you have a use directive so you might have a file and at the top it's going to say use such and such class and then you can be using like five different classes all of that technology in this file so use a class is the same as include a file and now you can access all of the methods and the properties that are inside that class that you said and you can use in this file so in Drupal all controllers, routers, forms and plugins are all actually class files and they use each other extensively and you'll see that and so in general all the functionality created in Drupal 8 and including in your custom modules is going to be created in class files there really is no other way as it as it works as the framework works now in Drupal 8 it feeds through all your modules it looks for an expected directory structure that indicates to the framework what you're trying to offer then it looks for certain types of files within those directory structures and then it looks for a certain type of class construction inside those files when any part of your module construction does not meet those standards you'll have a fatal error or your technology will go unrecognized essentially what's happening in Drupal 8 you know how in Drupal 7 someone will do it in an include file or in an admin form include file and you could find technology in like 5 different places that's just not going to be the way you could build a block anywhere you felt like it that is not how it's arranged in Drupal 8 a block is expected to be in a plugin directory in a class file with certain 3 methods inside of it that build that block and you have to have it that way or you will not have a block so an interface is a special kind of class that it says here has empty default methods inside and so if you want to say there is a class that says you know I'm an email service and I'm an interface and I have 5 methods inside me but you want to create your own custom interface or emailer so you use this interface and now you can take all of its methods and in fact you must use all of its methods but then you change all the insides in those methods and that's how you make your own custom emailer based on an emailer interface and so when you look around in Drupal you'll see that everything, every service that Drupal Core offers starts as an interface they build the interface and then Drupal uses its own interfaces in classes to provide you services and so down below along the bottom you implement an interface but you extend an abstract class so an abstract class is similar to an interface it offers a bunch of methods but you are not obligated to use them when you extend an abstract class so again like I said you know through a lot of stuff we can't go into the specifics of everything but I'm confident that you'll be going right I see and that later when you see this structure inside Drupal when you're looking around you'll recall this information a trait and there are trait files in Drupal is a group of functions that do a lot of the same thing so they've been conveniently put into a single file so that they're organized and classes can use traits to get the functionality out of traits and that is how it is actually done in Drupal so PHP object-oriented reading there's two, I have two links here PHP Freaks and Java 2s these are pretty old like 2008 2010 they've been online for a long time but these are excellent if you're just starting in object-oriented and you want like a really excellent intro both of these pages will get you started there's also an object-oriented session coming up that you can still attend here and it looks like really good dependency injection so this is a big thing in Drupal 8 it's in use in a lot of other frameworks but essentially what dependency injection is you have a class again it sends email but how it sends email right is could vary you could use an SMTP server you could use a pop3 server right you could use some other strategy when you build your class and you go and you hard code inside every time someone wants to use the email service I'm going to use SMTP this class is now a little too brittle because it's always using SMTP so you can say okay someone will send in a parameter and I'll do a check and if they say SMTP I'll use that, if they say pop3 I'll use pop3 so then again now every time you introduce a new kind of mechanism for sending email you got to go into the class and change the if structure or the case structure and you're rewriting so with dependency injection you actually tell the class when you instantiate it I want to use SMTP as the service and so you tell the class what you wanted to use to do its work and it just takes that and does the work using what you told it to do that is essentially in the shortest possible amount of words what dependency injection is it is used pervasively throughout Drupal 8 you're going to see it everywhere and so in class files at least in PHP there's a certain function called construct that is headed by double underscore so construct is the method that fires immediately automatically as soon as you instantiate a class and that is where you can expect any parameters that have been passed in to be when your class gets instantiated so when you're writing your class and someone has passed in parameters it is in the construct function where you can expect to find them and immediately work on them and evaluate them and do things you need this dependency injection article by Fabian is super excellent it does happen to be four sections four pages long and it's extremely technical but if you want the total low down on dependency injection from A to Z that article will give it to you so services are classes we've been calling them objects for years but in Drupal they want to call it a service because it does something for you and you can go and take that service from that class and so anyway that's going to be a class file your plugins which make blocks and support views these are all going to be class files also comments and special comments called annotations I've seen a lot of code and I know that writing comments and writing truly accurate comments according to the standards that comments are supposed to meet can be consuming can even seem like timey, taxing well in Drupal 8 self documentation is actually pulled out of your comments so when your comments are structured correctly according to how Drupal wants to see them it can create documentation as it reads through everything out of your comments annotations are actually special comments with special formatting that Drupal actually reads and other frameworks do they read through your annotations and understand the framework what your technology does and if your annotations are not correct your technology is misunderstood so in Drupal 8 it is still plausible to get by with not writing the correct comments but like in plugins where annotations are expected your annotations must be accurate because they are describing to the framework what my plugin does so I have the special links down there both of those articles are really excellent how you format comments and annotations in Drupal so I highly recommend it this is just a couple of offbeat items method chaining we've all seen that if you look at that example across the bottom that's from jQuery everybody's seen that kind of thing where multiple commands are just chained together for the longest time I never really understood exactly what it was or what it was called and it's actually called method chaining and the reason why it works by jQuery can take the edit button change its color slide it up and slide it down all in one long command is because every one of those commands CSS or slide up or slide down actually returns the entire edit button object again and so that's why every method in the chain can work successfully on the object because it keeps getting returned by every method in that chain so you've seen something on multi-line like that and that's a D8 example I know you've seen that in Drupal 7 or 8 multi-line method chaining but that is what's going on there DB update is like the object and then it's executing condition on it which returns the object again which executes fields on it which returns the object again and then it is finally executed so that's what's going on in method chaining shorter race syntax since PHP4 is used throughout Drupal 8 is the short array syntax you're probably familiar with this too and I never knew what these were called but I had to look them up so when you define an array with the parentheses like that that is called a constructor function but if you just use those two braces which equals the same thing that's the short array syntax so I'm showing you the examples there so this is not like anything very mysterious you can see this everywhere in Drupal 8 there are almost no array constructions using the old style technique they're all using the new short array syntax type hinting type hinting is when and I'm sure you've seen it and you've probably used it but if you write a function and the parameter coming in you need it to be an array or it must be a boolean or it has to be an SMTP object so right in front of it in the function you describe what should this variable be on the way in so like in the first example I'm saying page has to be an array to come in here and in the second example it's saying event has to be a filter response object on the way in so and when you do this it handles the validation for you and if someone does try to send you a page item that is not an array PHP will throw the fatal error and stop it and very succinctly say line 98 files such and such not the right type and so you don't have to handle that go in there and write the if statement the endless possibilities maybe they sent an array or a boolean or a blank or null PHP will handle that for you if you're not using it yet and explore it now we get to Drupal 8 again this is my crib notes this may not work in your environment exactly but it can this is installing Drupal 8 from the command prompt cloning it right out of the Drupal Git repo immediately creating a new tag off of it making the files structure that's needed setting up services YAML and settings PHP preparing them to be written to by the Drupal install and then changing them back to secure settings and then after all that happens running composer install which is going to pull down symphony and all the things that belong in the vendor folder again this is available as a reference further with a couple more commands you can prepare Drupal 8 for debugging which is really nice so what you tell it to do in your settings PHP file you tell it you uncomment a single line that says oh if you find a local settings PHP file at the peer level with me please pull that in and in that local settings PHP file there's a bunch of directives to Drupal that says hey if you're going to throw errors throw them in a really verbose more regular English fashion and then you're debugging when you have errors in the vendor and more specific because of that change and then of course you need to change that back of course when you go up to test and go up to live and then the final one is using drush to enable the develop module and here's a beautiful thing about develop in Drupal 8 they added a new tool in there called the web profiler and so what the web profiler does when it's enabled on every single page you're going to get this little tool bar across the bottom and it tells you everything it's like an x-ray of this page every controller that was called and used to build this page every theme, every set of functions every MySQL query everything that happened to build this page can be found in these little icons across the bottom you can actually link them into a deeper report where you can get like a report version and everything is linked like if it says I use this controller in Drupal 8 site so you can navigate to the controller that handle this page directly so that's the web profiler portion of the develop module in Drupal 8 I believe they're back porting it to Drupal 7 or it is already in Drupal 7 this is just a quick look of what the top level directory structure looks like in Drupal 8 after it's installed the only thing that's really important is that the modules directory is now at the top level in Drupal 8 and down and this is actually where you're going to be putting your contrib modules and your custom modules is right here in the top level modules directory everything that is in core that belongs to core is now in this core directory and is not located any place else in the site and then themes is where your themes are going to go vendor is the vendor directory I've been talking about we're all the supporting libraries including symphony are pulled in this directory is still the sites directory if you need to make extra sites whatever you're doing for multiple themes you can still use the sites directory for that and in fact settings PHP is still located in sites default this is what's inside the core directory again this is really just here for a reference and now this is what I'm suggesting to you this is not being forced on you I've been in enough environments to suggest this that once you get inside the modules directory you should make sub directories called contrib and custom and there's actually some modules that look for this and then so all the contrib modules that you download you put in the contrib directory and all of your custom modules for your site you put in the custom directory and this way there's no doubt am I looking at a contrib module or am I looking at something we built and this distinction helps you have that immediately this is a typical droopalate module structure at the top most level there's a bunch of YAML files then there's a config directory and a source so in that config directory is the YAML file that's going to have your default settings that you would like when the module is enabled and then in source is everything else that you have built for this module all of your class files so and again this is not an optional style of formatting your module directory this is mandatory because the framework is going to look in your source directory and it wants to know do you have an event subscriber going on do you have a form going on if they're not located in this directory structure it won't get found so that's you know that's really the purpose of that so YAML files back in Drupal 7 on the right hand side .info file is now in the .info YAML file and everything is prefaced by your module name for organizational purposes every hook menu is now in the routing YAML file every hook menu where you wanted something to show up in the admin section of Drupal is in links menu YAML your permissions in permissions YAML and then you have your services YAML to describe the services that your module is going to offer so and this is a quick look at what a services YAML file might look like in your module you can offer several services which is what's going on here the first thing is it's got to say hey I'm offering services so that's the first top level item this is a service whose machine name is Tracking Inject Manager it is being actually handled when it's called for by the Tracking Inject Manager class and then it accepts a database as a parameter so that's essentially what you're going to see in a services YAML file the bootstrap here's what's going on when Drupal bootstraps it reads settings PHP it generates some other settings it starts up the class loader to start reading through the framework and getting all your classes sets up an error handler and then it detects if Drupal is actually installed creates the Drupal kernel and initializes the service container so the service container is what Drupal uses it goes and it reads through core and it finds everything core offers it offers to you and puts it actually into like a gigantic object basically and it says this is everything that Drupal offers to this website so I'll talk about it a little bit more so then it adds the container into the static classes it attempts to serve your page from the cache loads all the variables loads other include files registers stream wrappers HTTP request object lets the Drupal kernel handle it and return a response and then it terminates the request okay if you know hooks so there are some hooks remain in Drupal 8 but most of them have been removed in favor of an event model and you subscribe to events so these are a couple of very good links that describe that for you and I'm just gonna illuminate here the main events that the Drupal 8 kernel offers there's the controller event which is the time when your request at such and such URL gets met by a class to respond to it when that happens the controller event fires if there was a mistake you get an exception event when the request is finished a finished request the initiation of the request the response the initiation of this entire act and view so this is just an interesting side note here if your response terminates and Drupal is hanging there and says wow I can't figure out what you're returning I don't know if you really returned an array or if you returned a response object it will actually in a final effort called the view event try to turn it into something that it feels it can return and process it as if it's a renderer array and try to turn it into HTML and present it to the user so that's what view is doing there at the end this is an example event subscriber so what's going on in an event subscriber so this is where you say hey hook init right hook bootstrap so instead you're going to subscribe to those events I just described and you're gonna make a class it's gonna be in an event subscriber folder inside your source directory when you make this class it's actually implementing the event subscriber interface so you must use all the methods that are in that interface and the first method is to tell it what event you would like to subscribe to in this particular case it's the request event and then that array after that is saying run the initiate tracking function which is inside this class on the request event and then inside the initiate tracking it actually gets the response event as an object passed into it and then in this particular case commented out it's a it could you know it's writing you know it's echoing something to the screen or you could actually take actions that is predominantly how hooks are being treated now in Drupal 8 changed instead to event subscribing core functionality in Drupal 8 such as the current user current path node info who's logged in does a module exist all of these you get out of the core service object that I described earlier where everything is packed into one big object and that object is actually called Drupal as you could see at the end backslash Drupal will get you access to everything that Drupal has created in this particular bootstrap so an example would be I grab Drupal I get its module handler method and then off of that I say you know I want to check for module exists and I'm checking for the content translation module and this is going to return true or false so if I want to get the current user I set account equal to Drupal get me the current user I want to get a piece of configuration I say Drupal get me the config of some module name and get me its settings and you're going to get a settings array back from that module out of which you can cherry pick what you need to use other examples of using Drupal core services this is to get the second line is to get the request object to get the exceptions off the request object to get the status code off the exception okay so everything that you used to remember from the conf and everything you used to use variable get and variable set for that is all changed to this type of get from config and write to config so this is actually like a pretty sophisticated topic and it would be a whole show on its own to go through all the variations on configuration and grabbing settings and saving settings so but I'm just like telling you it's a big thing at the end is a nice example where you're using the Drupal core object and you're saying please from the config of the system please get me page front and this is how you're going to get the home page if you need to grab the home page some more things you know getting variables and setting variables so you cannot actually set a variable in the same simple way that you read it you have to instantiate a config factory get the editable version of the setting you would like to change then change it and save it and if you don't do all of those steps your change to that setting will not happen correctly and then down below is un-setting a variable by using the clear method on it and then saving the fact that you have cleared that variable so again some more reiteration types of getting settings and setting settings okay so caching caching if you haven't looked into it deeply I know it can seem like really a lot of work again similar to comments okay but for anybody who is not completely clued in on caching and hasn't studied it a little bit you're going to have to as you move into enterprise environments you will become you will be talking caching every single day non-stop it is the only way that large scale websites that get thousands and hundreds of thousands of hits and millions of hits can actually survive that experience and get pages out they have to be cached so basically there's two things about caching you know you got to cache something and then you have to invalidate it when it's gotten too old and you want to refresh it and it needs to be new so that's the two basic concepts I cache things by saving things in and then I invalidate them by removing them out of the cache and there's just a nice quote here from Wim Lears who talks about it and I thought it was very good so I just put it in there you know you can read that so here is other key concepts about caching like I said we can't go into all of them but I've given you some really good links and there's a big pipe session but this is all the key sort of things you should know about caching in Drupal 8 if you can take the time to read on these topics and newest is the one that's linked on the top called the big pipe and here's an example of big pipe so borrowing from Facebook what Drupal 8 is doing for you when you do all of your caching correctly and your module uses the caching model in Drupal 8 correctly you can cache little portions of your page you can cache a block you can cache a section you can cache the footer all differently from the cache status of the entire page so when Drupal builds your page and it looks at all the granularity of your caching it actually keeps track of all of it for you and then it says wow I believe I can deliver the framework of this page 100% cached as I'm showing here on the left side all that gray matter but only three items uncached because I followed all of your tags so what I'm going to do for you is I'm going to deliver the entire cached framework really fast to the user and they're going to get a page up and there's going to be spinners and little pieces waiting which you've all seen so then in the big pipe concept Drupal will continue to stream the uncached portions into the page much like in Ajax command where after the page loads you use Ajax to pull in more stuff this is essentially an Ajax technique but it's being done by keeping your HTTP connection open and continuing to pipe things up into the browser so now these extra units are piped in that were dynamic and not cacheable they come together at the end finished page for the user that's the concept of big pipe this is a fairly technical explanation which I borrowed right off of Drupal.org but I found that this particular little section explains caching in Drupal 8 about as thoroughly and succinctly as it could be done so I put it here for you cached contexts when the thing you're caching is going to change because of language or cookies or a route or because of a session or a change theme if you're caching changes in the URL or there's something different about the user you can tag your render array to say my cache context is to change on user and then so Drupal will know if user has changed I need to render this piece individually again for this user and it will not send accidentally the cached version from the previous user so again if you're caching things correctly you can have this kind of granularity throughout your caching in Drupal 8 you can also just cache things and then invalidate them based on a time you can say every 5 minutes, every hour every 3 days you can set it I believe to 0 for it never expires and so you can have a cache get invalidated because the user changes or the URL changes in 5 minutes and you can do both of them at the same time so that if the user doesn't change but 5 minutes will go by the cache will get destroyed and it will get rebuilt on the next request anyway so now here's a render array now when you make a block through the block plugin you don't have to but Drupal 8 is really requesting that your block output will be in this type of render array example and not return a string of HTML combined with data so when you look at this render array you can see that caching has a prominent top level key and all the things that can help add the granularity to the change and expiration and invalidation of your caching can be supplied here so this render array basically under context is saying if the user changes this render array has to be rendered again if we look at tags it's actually saying if node 42 in English changes this render array has to change here again and has to be invalidated and rerun if something changes in the config system performance section this cache has to be invalidated and built again and then you see it has max age 300 so I don't know what is that that's like 3 minutes or 5 minutes so then it's saying or if max age is more than 5 minutes this render array has to be invalidated and rebuilt so that is how you put the granularity into all of your output and then in this render array or all those other details like you can put a prefix in front of your output you can have markup in your output you can have a suffix after it you can have a theme you can fire off a pre-render function which will process the info that's getting passed into this render array for you again before you use it if that's what you need most importantly is this attached feature down here when you need to include custom css or custom js just for your little block that you're loading with this render array you attach it here and then when you attach it this way instead of putting it in hook and knit or trying to put it in your theme file or something like that and then it gets loaded on every page for no reason Drupal will look at this and go only on pages where this block is actually loaded will I include this css and this js and that's how you get your granularity and you don't have to have if statements all over your website saying if it's in a user section please include this js etc etc you do it here and you can have very granular inclusion of your js and css this is a really quick look at twig and how variables are output in twig, they're inside double braces how conditional logic looks filters, attributes and just importantly when you put a variable in the middle of some html you don't leave a space they don't expect you to leave any spaces around the braces it's just supposed to touch and be sort of like a continuous so again you can look at this in your own time so the routing system in d8 is basically like I had started to discuss earlier if you have a path in your website forward slash contact so that goes into your routing yaml file and in there it says when someone asks for forward slash contact execute this class and so that's basically what we're explaining here and then this is what your routing yaml file will look like that achieves that right away in the routing yaml file for your module your route is going to have a machine name and typically we would prefer that it is it has your module name and then a period and then the name of the route so then it is followed by the path that responds to this here's the controller that gets executed on this request and on top of that double colon it's actually saying go into that class and execute this method on this particular controller call and then this is the title of the page and this is the permissions to access this page there may be a few other attributes that you can put in here but this is your basics and this is how you create a custom route for a single URL that your module is going to control or respond to so this is a very good link to a very high quality look at how to make a block plugin correctly really quick and so like I told you that is a class file with three methods you must use that are located in the source directory in the plugins folder under that and that's where your blocks have to be to get recognized by the system the configuration management initiative if you've done a lot of Drupal 7 you probably know you've saved features you've taken them over to live and then you've imported them into live and then you've had feature conflicts and you find that you're exporting content and names of nodes and things which features was not designed for and then that's getting mixed up with true admin settings that you do want to move from dev to live and you get a lot of potential aggravation so in the content management initiative Drupal is handling all this for you Drupal will basically scour your website and go I found every piece of admin setting that you've got and I'm going to export it as a YAML file and save it in the defaults files directory under some cryptic just invented long name that's like unguessable probably a UUID I believe is what it uses so and then you can actually put that in Git or however you're going to get it to your live site and now on the live site you can go please import that config and everything that just got exported out of dev or out of test will get pulled into live so no using features to do it no hand transcribing no putting commands in your modules to create admin settings you just export them all with one click and then you import them with another click at the at the target website so and to make that even nicer there's a configuration inspector module for Drupal 8 that will after you install it analyze all your config and put it in a beautiful admin page report linked to all the admin pages who's creating all these config settings and show you all the config settings from all of these modules it is extremely handy if you need to X-ray a site so for example you come to a new Drupal 8 site you don't know anything about you quick install this module you go to its report page and you see everything that's getting built and has settings in this website very cool the Drupal module upgraded I've never used this product but it has really good reviews when you read about it so you can actually you'll install this module point it at your existing Drupal 7 module and it will make its best effort to convert it into a Drupal 8 module on the fly for you so I'm sure you've seen concepts like that of turning D6 modules into D7 modules and you know that your mileage may vary so your mileage may vary here too but this will at least get you started and I use the technique like this once to go from D6 to D7 so not only did it achieve like 80% of it the other 20% it was like hey this is the part I can't convert and like right here this was the function I could not convert you're gonna have to finish this yourself and it's gonna be accurate and it turned like a huge time consuming chore into like a one day effort and so it's possible that this could do this for you simple test and PHP unit testing in Drupal 8 so like I was talking about I'm just kind of doing this sort of like as an evangelist again like I indicated I am not a totally a testing expert but I've been in enough environments and around enough jobs to tell you that testing eventually testing is eventually going to be important and testing is eventually going to be vital so simple test is the module and the strategy that is still used in Drupal 8 for creating interface testing basically where like you want to check does the login work when the fields are filled in and someone hits submit if someone puts in bad fields does it break or does it show the message you can use simple test to achieve that kind of testing and PHP unit testing on the other hand would be you write a module and the module is supposed to return centigrade when Fahrenheit is passed in so you write a PHP unit test that sends in a valid centigrade sends in words or strings right sends in whole sentences and you see how does your module end up responding and then if it breaks because it's sent in a string and you're not checking for that you know you need to fix that so that's the type of checking you can do with PHP unit and so with PHP unit you can also like using dependency injection and this is where dependency injection becomes very valuable and is actually at its like best usage case so remember like we were saying okay you've got this email class and you want to tell it when I instantiate you use SMTP and you inject it into the module so now say you're on a dev environment that doesn't even have a connection to the internet what you can do instead is you can build a dummy function that says oh I got an email address parse it correctly oh it has an attachment parse that correctly too and then if you have success return true and you can call that my testing emailer object and so when you go to test your emailing instead of passing in a real SMTP service object you pass in your testing SMTP service object and if your testing injected item works you know your thing is working and then you can purposefully break it with this testing item and see how your product responds when you purposefully break it so that's where dependency injection like really shines and why in large environments you're going to see dependency injection in use. I have a couple of handy links to PHP unit and to testing in Drupal 7 and Drupal 8 and those are very good links. It is possible that in the near future and there's discussion about it about putting B-hat, the Drupal extension the Mink extension, Mink, Goot and possibly Phantom JS all into Drupal 8 and this is another strategy for testing the interface of your website but what this provides is through B-hat and the Drupal extension and the Mink extension and say something like Phantom JS you can write a test that says hey crack open an invisible browser Phantom JS go to this page on my website fill in the form hit submit test all these Drupal functions on it see if I got success and call that a test because the Drupal extension will allow you to call like Drupal functions from inside your B-hat tests it's actually like really slick once you understand the concept and then you can write very elegant sophisticated tests against your site using this great combination of JavaScript and deep Drupal but this is just a dialogue but you can do it yourself like you can set all this up on your own website and run it all yourself so a quick note here you saw from the beginning the big ecosystem that comes with the Drupal 8 website potentially varnish caching, Nginx Splunk, Jenkins everything, all these things operating on your website and your website environment so today there are several services that allow you to basically roll out a Drupal 8 website with a click of a button and one of them does happen to be Pantheon and from this perspective how this could be looked at is just like Drupal has gone outside and said look I use product that is proudly invented elsewhere to build a better website so you could use a platform like Pantheon to build a better website without you having to have to build the entire service structure yourself and have three or four people rolling it out and maintaining it instead you buy as a service the platform that runs Drupal for you so I can tell you from having been on the outside and on the inside there are a lot of very nice advantages to having your Drupal platform as a service and having all of that off your back and having excellent tech support to call and say you know why is that not working well you are up tonight between 11pm and 3 o'clock in the morning figuring it out yourself et cetera so there is actually a website called Try Drupal where there's several Drupal platform as a service tests available and in particular the one on Pantheon you can set up an account for free spin up a Drupal 8 website start installing modules on it start testing it hit it use it and it's all free training resources I've done a lot of reading ahead for you if you haven't ever looked at Drupal IZME build a module KMP University these are all endless amounts of video tutorials on Drupal 8, Drupal 7 related technologies some of these are free some of these cost 20 bucks a month for unlimited access so if you have not in your career spent money on yourself education wise I can tell you that a $20 subscription to one of these websites and you go on there and watch 10 videos over 3 weeks time you will get your money's worth Safari books online similar thing I don't know if it's 9 bucks a month or 20 bucks a month you actually have digital access to every book O'Reilly has ever done on programming so in a month you need to get up on Java you have 20 bucks to Safari you grab 3 or 4 Java books digitally read all the parts of it that are important to you any device you want to anytime you want for 20 bucks a month if you need to catch up on something this is a technique I didn't know this until a while back and someone enlightened me though but basically every presentation ever given at a Drupal con event has been recorded and is stored on YouTube under the Drupal channel and so you can see a lot of really valuable educational work and that is the end thank you I think there actually is time for questions if anybody wants to ask a question I think we have 3 minutes but I find that nobody really has the wherewithal to do it but go ahead yeah in 7 there was the library's directory yes is the vendor director and composer going to replace that or do they still both exist they actually still both exist right but I think the idea is we would really like your custom module and everybody's contrib module to put it in vendor and then use composer to manage it and you can put your own composer.json file in your module that would get used to deploy and maintain it correctly as you need it hello yes go ahead so you talked a little bit at the beginning about the headless Drupal are there any SDKs available for any other languages or even PHP for interacting with Drupal or is it just through the rest AP opera right now you know I think someone made a mobile like SDK for like sencio or somebody for talking to Drupal but otherwise I think it's basically it's roll your own on top of that so can you access nodes can you access like view results like paging wise what is available with everything available via the rest API basically that's a great answer I'm wondering if you could talk a little bit about the structure of namespace for contributed modules in particular I believe it's Drupal and then you skip the source directory and then it's everything below that yes it is and that's so easy to reference and in fact what I could tell you is I wanted to mention this to everybody the Google Analytics module the Contrib Google Analytics module is just like an excellent example of everything to do correct in a new Drupal 8 module and you can look in there and look at the site structure and how things are included and everything and you'll have it very accurately from there I got to tell you Pete great job it was a whirlwind information I was following along with the slides that I downloaded from the link in the description I don't know if you made some updates recently I did this morning at 8.30 if you could push out another file it would be fantastic because it's like a survival guide the one since about 8.30 this morning is completely current alright great thank you