Drupal 8: What You Need To Know

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
this is Drupal 8 what you need to know my name is Wayne acre I originally gave this presentation at Drupal camp Michigan and I'm rear according it for release on Drupal tutor.com in this presentation I'm going to do sort of just going to be a brief overview sort of dog and pony show lots of cute animals and I'm going to show you the best new features of Drupal 8 so specifically I'm going to talk a little bit about the Drupal 8 development process I'm going to show you what's new for end-users site builders themers and developers I'm going to talk about the state of Drupal like development as of today and then I'm gonna talk about how you can help the effort further plate to get Drupal 8 out the door and to make Drupal 8 great as I said I'm Wayne acre I'm an independent Drupal developer site builder and themer I'm the maintainer of the node gallery in menu badges modules as well as several other modules and I teach online drupal training classes at drupal tutor calm my drupal 8 experience i should say right off the bat i'm not some super elite core developer i really just started working on some drupal II work at Drupal con Portland I just showed up at the sprints and said hey how can I help I got pointed onto some specific issues the largest one was sort of a conversion of the update data fetching part of Drupal cores to the part that fetches information about new module updates and sort of converting that to the new coding style for Drupal 8 in addition I have already ported the menu badges and linked badges modules that I maintained to Drupal 8 I did that back in September so between those two I think I have a good feel for the new features of Drupal 8 and the type of experience that module developers are going to feel when they move from Drupal 7 to Drupal 8 this talk is not my own alone this talk has been given by several people before and it's sort of the I've cobbled together the work of a lot of different people so a lot of different blog posts other presentations and so here are some acknowledgments to all those who have come before me and who I got a lot of information from I've also got extensive footnotes for a lot of add on blog post places where you can go to learn more about each of the topics that I'm covering if you go to Wayne Acre calm slash triple-eight alright so let's talk about Drupal 8 development in January 2011 Drupal 7 was released and three months later Drupal 8 development began Drupal 8 development differed from Drupal 7 development in that Drees the leader of the Drupal project sort of created a series a set of lieutenants who are in charge of various initiatives and so these were the official initiatives of Drupal 8 mobile configuration management html5 layouts multilingual views in core and web services and so there were different people in charge of each of these different initiatives and by sort of splitting up the work you know they've really been able to get quite a lot accomplished over the last two and a half years oh I should have mentioned actually they were in addition to there's official initiatives there were a few unofficial initiatives like the twig spark which is UI improvements and there were several others so here we have two and a half years later there's been over 1,600 contributors to Drupal 8 which is nearly double that of Drupal 7 this is by far the most changes of any group or release you'll see when we get to the code section there's been really quite a rewrite of the core system and I think that Drupal 8 personally positions Drupal to be a Content engine across multiple platforms and it's not just for web sites anymore I want to talk a little bit about that when we cut get to the web services part all right so what's new in Drupal 8 so let's start with end users what are you users going to see that's new first thing it's Drupal 8 is way better on mobile phones than Drupal 7 so I have just a few screenshots to sort of demonstrate this it has a response to all the built-in themes have a responsive design so here's Bartek the default theme on Drupal in Drupal 7 in Drupal 8 so you can see that it's with the responsive design it's collapsed down on the phone by default and I should say all the screenshots in this presentation are all Drupal core there are no contributed modules or add-on themes this is all Drupal core both for the Drupal 7 screenshots and the triple-eight so better themed a better thing for mobile edition on mobile if you've ever tried to admin paid rupal 7 website on your phone you know that it's really a pain the admin bar sort of wraps around here like this and I don't know about you but if I if I have to hit this structure link it's dangerously close to the logout so I've had a lot of frustrating experience as a competing struck trying to hit structure and end up with my fat thumbs hitting logout so the admin bar has been rebuilt so that it's easier to use on mobile phones as well it goes sort of vertically like this and it's actually a responsive toolbar so when you're using this toolbar mobile it has all the same features but in a more spread out horizontal view responsive design goes for the forms and the admin theme as well so over here our Drupal 7 and you can you get this tiny sort of look on your phone and on Drupal 8 it automatically classes down to something that fits nicely all right next big improvement is WYSIWYG and core so in Drupal 7 and all drupal's before it when you install Drupal and set it up out of the box this you would have an editing experience something like this no WYSIWYG you are can put in some HTML but you've got to read some down in here like what you're available tags are and whatnot in Drupal 8 this is your default experience includes a wysiwyg Brau WYSIWYG editor CK editor and some of the node form parts have been put up here on the sidebar so these are the things that used to be at the bottom in in vertical tabs there now on the sidebar and this works these actually do collapse back down to the bottom when you're on a mobile phone but when you're on a wider desktop they're here on the side the other important thing is that the published flag it used to be a checkbox it now sort of has worked into the buttons so this button has a little drop-down so you can see the default is save and keep published or it will say save and publish if it's new and you can pop this open from the little arrow and if you wanted to save and make it unpublished you could do it right there from the button because a lot of people miss that checkbox you know cuz it zipped up into a field set in Drupal 7 so this is an improvement here I think it'll be easier for people to find how to save unpublished content or to publish on publish content alright inline editing so you can edit nodes in Drupal 8 without even opening the node form and I'm gonna show an example of this I've pre-recorded all my demos for this talk so I'm just going to show you a video here and I'll talk through it so the the contextual links here allow you on a node to edit individual fields and save them you can also edit multiple fields you just choose this quick edit option and then you hover over the field that you want and you could change you know one or more things and then save it with a little pop-up and it saved immediately okay you don't need to open up a form this even works for WYSIWYG enabled text areas so you can see there's like a mini WYSIWYG toolbar there I can bold some text I can add things into the text area and oh here I'm going to make a link all right so that's pretty smooth edit notes without having to go to the forum file field multi-select I'm really excited about this one this is one thing that really really annoys me it's a very minor thing but I think it's just one of those tiny things in Drupal 8 that there's so much better so let me just show this to you so if I have a photos actually sorry let me back that up a second here I have just a node and I have an image field down here for photos so let me play this if I choose files I can actually choose a bunch of files with the shift key and it will automatically fill in all of these files and upload all the different files at once if you've ever done this on Drupal 7 you know that unless you have an add-on module like PL upload or something you have to do them one by one you can't just select a bunch of them and have it to fill in like this so personally I'm really excited for that form elements in Drupal 8 have been replaced where possible with html5 compatible form elements and several field types have also been combined in have been put into core that used to be in contributed modules so for example there is a URL field in Drupal core you used to have to install the link module to get that same thing there with email telephone and date those used to all be add-on contributed modules they're all now those date those field types are all now in core and they use html5 compatible elements which has this effect here if you're on a mobile phone and you select the field so this is a normal text field I have a normal keyboard when I go to the telephone number it changes to a numeric keyboard when I go to the URL I get a URL specific keyboard with the com same thing for the email address I get like an @ symbol a special bored the photos will allow me to upload photos from the phone the file field uploads and if I have a date field it'll automatically use the native date widgets for at the device and this works on the Android too I'm showing an iPhone here but this would work on Android with the native Android widgets the tour module is a new module that's being introduced in Drupal 8 this allows you to build interactive overviews and help documentation for modules and it's used in Drupal core as well the only one I could find at this point that's actually implemented in Drupal core is four views so let's just see a quick example that we're going to start up here in the corner where it says tour so whenever you have an option in the corner you can click it and you can get sort of a walkthrough where it points at the various buttons and has help text alright and so as I said the only one I could find right now is it's built into quartum in the development version right now those views but theoretically these sort of tours and help text will be used throughout the Drupal core system and module developers can add their own tours for their own module functionality as well so hopefully this will catch on and it's a easier thing for people go through this then the standard droop will help now let's take a look at what's new for site builders so in bi site builder or what I mean is people who create Drupal sites but maybe don't do any coding on them so people who build views people who have to have to install and configure modules and things like that set up new Drupal sites so the first thing that you'll notice if you download Drupal 8 is that the directory structure has changed so if I asked you the question where do the downloaded modules and themes go in Drupal 7 I hope that all experienced site builders will may they go incites all modules and sites all things in Drupal 8 that's no longer the case they go in it straight into the modules and themes folder at the root level of the Drupal folder and all the core files that those used to have core modules and themes in them all the core files are now in a directory called core and so I know what you might be thinking wow isn't that exactly what we've been taught not to do or what we've trained other people not to do for years because usually it would be only noobs now new people who would stick their modules and themes in mods in the root level modules and themes folder this is now the recommended practice however the sticking modules and themes and sites all modules and sites all themes will still work so if people follow those old directions it'll still work you can also still use specific site names so if you have a multi-site install you can still do you know sites domain name modules and sites domain name theme as well that still works and in fact if you're going to have specific ones for specific in domains you still have to do them that way configuration management um in Drupal 7 we have some issues with configuration management the main one is that configuration lives in the database and deploying the config changes from development to staging and production is hard alright how do you get this stuff out of the database and how do you put it onto production server without removing all the content from the production server because the content is also in the database you can't just overwrite the whole database and this is a problem that other systems have I was just talking to a wordpress developer last week and he was lamenting that they have this same problem in in Drupal we have an additional problem is that we have inconsistent formats for configurations some modules use c 2 c 2 exportable formats some people put their things in into the variables table some configuration might be in their own custom tables okay in the modules on custom tables so it's kind of all over the place there isn't like a unified way that people start configuration on Drupal 7 the community has sort of solved this problem by using the features module and for me personally I love the features module allows you to export configuration with the database push it up to your production server and then deploy those configuration changes it works really well it covers probably 95% of the configuration changes you want but it's sort of a pain to use and it's this is not the fault of the module developers this is an amazingly difficult task to accomplish because of those inconsistent formats wonky things can happen with features sometimes you have features that don't revert or force things that or the features do say that the changes have been deployed and they don't show up there's just a lot of weird things that can happen with features so it's it's not the best approach but it's the best approach given the underlying architecture of Drupal 7 which is sort of inconsistent and everything's in the database Drupal 8 we've got a new solution to this problem which is a new configuration system where this sort of canonical version of the configuration is stored in the mo files and not in the database this allows us to well a it's human readable this is an example of a mo file so it's also human editable so this for example is the display settings for an article teaser so if I wanted to change the trim links from 600 which we can see right here if I wanted that to be 800 I could actually hand edit this these files are just text files so they can be version controlled they can you can deploy them with git or subversion or whatever and what you end up with the way this looks in your file layout is you get under your site's default files yeah there's this config with a big key here directory and then you end up with two folders under here active and staging the rule in Drupal 8 is don't hack your active config okay so all of these files you'll have like a ton of files like this in both active and staging directories they will most the time probably look the same but do not edit your active config the way you should do this is if you want to edit Handa to the file where you want to overwrite a file you do it in the staging and then there's a synchronization process that I'm going to show you here where you synchronize the settings from staging instead of import them into the active config and so I'm gonna show you how to do that now I'm not going to show you it with git and rush and some of those tools it is available to do with those tools but I'm going to show you something that anybody can do this is just someone maybe who's even just managing their site with FTP and they've got like a copy on their laptop and a copy on the server even people who are working at that level can take advantage of this configuration management system so let me show you an example that here in this video so here I am on the development site I'm going to go to the configuration site information I'm going to add a slogan to my site okay and you can see the slogans there up here at the top and then I'm going to go down to configuration management and the site that will actually already detect that I have a change okay that I've added the slogan so I'm going to export the site configuration and so that went a little quick there but what that did there when I it exported a tar file which is a collection of all of those configuration files that I showed you in the file the huge list that was in the folders min ago all those get tarred up into one file and gets downloaded and so then when I move to the staging environment okay now I don't have a slogan missing up here okay so I would go to configuration go to configuration management and hit import and this is where I'll upload that configuration tar file and it'll unpack everything and it'll put it into the staging folder okay it's not going to override my active config there's a second step where I have to choose to import it where it brings it into the active config and once that's done here is my slogan so I've just deployed that change now this actually works for all types of configurations so if you want to make things like oh we want to change which fields are displayed on article teasers you can make that change and deploy it exactly like I just showed you can do the same thing with views basically all configuration in Drupal 8 and hopefully and contributed modules for Drupal 8 will be driven through the system so you should be able to deploy them as easy as that and as I said before that will also work with git we could bring it down into the staging and virus or pull it down to the staging environment and then do that synchronization step to deploy it interpolate blocks or entities and so this might not be might not be immediately obvious the advantages this but let me walk through them so your blocks page looks kind of like it you look before it doesn't look radically different the first advantage of having blocks as entities is you can have multiple instances of the same block so this happens to me all the time where the client want to build in the site they want me to have the main menu at the top but they also want it in the footer and so Drupal 7 you know you probably have to install the menu block module and create like a second menu navigation or main navigation block in Drupal 8 trivially easy you can just you can make as many main navigation blocks as you want and same for other blocks if you want to have multiple copies that's easy to do in Tripoli you can also have block types so blocks and blocks can feel double so you you know in Drupal seven you have the custom block which is just sort of a WYSIWYG block of text if you want to have multiple different types this works just like content types in Drupal 8 so you can create multiple different block types add fields and manage display of them and then allow people to add different blocks of those types blocks are also revisional so this is really great if you have you know some block where somebody's coming in and manually editing on a regular basis if you ever need to revert that right now you there's no option really to do that in Drupal 7 interpolate you can just have the revisions turned on by default and you'll have all older versions of the blocks multilingual improvements I'm not like super expert on multilingual sites but I have had to implement it once and I one thing I remember about it is you had to download a whole bunch different modules in order to do there was a set of modules to do content translations and different set of modules to do interface translations all of that is built into core now and it all basically comes down to these three modules so I think it's a lot clearer and easier to get started with than it used to be English is no longer required for Drupal so if you want to have a site that's not English at all it's possible interface translations come through the update system so they're sort of this page looks like the the updates list for modules you can now do that for an interface translations and they can be updated when they're updated on drupal.org and you can go through actually and I'm not going to go through everything here because like I said I'm not an expert in this but you can specify which fields are translatable as as part of the field settings so if you have certain things like URLs or phone numbers those might not be translatable but then there might be other text fields that are you can specify that and then the interface will we'll be able to show the correct fields that need to be translated when somebody chooses to do a translation and actually the translation interface is similar than it used to similar to what it used to be if you've done it before there's a translate tab on nodes and you go in there and all the available languages are listed there and you can add translations if that part looks kind of similar alright next views in core that's pretty much it views which is the indispensable module for all Drupal 7 sites is now in core it looks quite the same if you look at this interface you'll see that it pretty much is unchanged it's changed a lot in its coding but the actual interface is nearly identical to what it used to be but now it comes with core this is going to help a lot because there was sort of a delay in Drupal 7 adoption because people were waiting for views to have a stable release before they built their modules and before they built their sites now that views is going to be ready on day one I think that's really going to help Drupal 8 adoption out of the gate there are a couple things that are different about views in core in Drupal 8 well I think our dimensions but the views are exportable within the configuration management system so they go through that hole just like I did with the slogan you can do the same sort of thing with views responsive HTML tables so if you can specify certain cells to drop out when when the table is put onto a mobile phone and views bulk operations is now in core so if you've ever used that module before now as part of the built-in views module system pages because of all those changes that I just mentioned system pages are now views so the default content so would like that this disappear this view is what happens when you press the content link in the admin toolbar admin people's the link under the people in the link in the admin toolbar all those things are views so you can easily override these some of these are kind of Reutimann I mean I know for example in the people one I always want to add like a field for searching by the user's name and having some other especially if you if you have first and last names and things on your site you usually want to have some way to search for those it's kind of a pain in Drupal 7 because you have to hide the other built in one and then build your own view all these are just views by default you can just change them and then it means have imagined the views are also exportable as EML files as I said earlier in this configuration system so I imagine that Drupal shops and Drupal developers will probably have a collection of yamo files that they put into every new project that they build right a replacement maybe for the built in people the built in people administrator the administration screen the content administration screen you could have like a you know three or four files every time you build a new project throw them in here synchronize and boom you've got your custom admin screens that you like too without having to rebuild them every time ok web services this is a big one this is one that I think sort of fundamentally changes the capabilities of Drupal 8 or a group of the Drupal project let's say in Drupal 7 and previous drupal's it's always assumed that the output you want is HTML when somebody makes a request to the web server or to Drupal always assume that you want HTML as the result that is no longer an assumption in Drupal 8 obviously probably most people who are going to make the request to you the Drupal sites in Drupal 8 are going to want HTML but it can also return XML or JSON representations of the data that's in the drupal system so let me show an example of this this is a I'm gonna show you example of web services for entities and remember all this comes with Drupal core so if you've used like the services module and things like that to build web services in Drupal 7 this is way simpler than that to set up I set this up in about 10 minutes what you're about to see I took about 10 minutes to setup and I'd never before so this is web services for entities this video so here I'm looking at node 4 and so here's node 4 it's a regular node it's got some fields it's got some files some image files attached to it and I'm going to copy that URL and then I'm going to go over here to this other tab where I have a rest client this is just this is you could do this with curl or something else if you wanted to use another client I have to change the URL a little bit I have to put slash entity slash node 4 and if I do that get requests here I will get XML cloud representation of the nodes of that particular node now that's great if you're you know if you're a Java developer or something and like a XML but for the rest of us I think we prefer Jason it's easier to read it's easier to parse and so here is the JSON value and the only thing I had to do there in order to switch is I add an accept editor for application Jason and so you know this gets a little programmatic here but you know you can do this with curl or you can do this out of like a if you've got some web app or so you have an iPhone app or something and you want to request this data changing these request setters it's pretty easy you can get that JSON data back and then you can put it into an app or render it in the app this also works for views so I want to do a quick example of that here's the home page of the Drupal site ok where we see several different nodes displayed and remember that home page is now a view because that's one of the system system pages so if I go into the view if I want to expose this as a web service okay here's my HTML rendered version all I have to do is add a rest export display and give it a path so I'll just give it views slash node and save it and once it's saved I can come back to my rest client put in my that URL that path that created view slash node yeah I've still got my Jason header there so and I will get back Jason representation of that view so here's the first node in that view was node 4 I highlighted it there and if you scroll down here's the second one node 3 and these are actually in adjacent array I know it's hard to sort of see that on the screen but so I've got all the data for this one and then here is node 2 all right and it goes on I think that one might be down there too but so this is I've got the view has spit back this Jason with the whole list so I could have you know you can imagine like an iPhone app on like a table or something that lists all of the content that's pushed to the front page and all that happens right out of the box I think i enabled like three or possibly four modules in core very little configuration I don't have an example of it but this these rest services also support post patch and delete meaning you can add new nodes update nodes that's what the patch is for and delete nodes through the rest interface so you can imagine building an iPhone app or all of the content and all of the is driven by the app including creating new content so I can imagine Drupal sites where you might not even have any sort of web but where the regular user doesn't even view the web okay so and that's why I say I said earlier the talk that I feel like Drupal 8 is really positioned to be a content engine for all different platforms iPhone the web and maybe even devices right where because these other other computer programs may want to talk to a Drupal site or push content into a Drupal site or or pull it out via these api's so I'm really excited about this part alright themers what's new for you not too much actually you get off easy comparatively especially compared to module developers the main thing is that twig is the new templating engine for Drupal 8 it's a symphony component it um doesn't doesn't it's a PHP it's easier to read it doesn't allow you to run sequel queries and in the twig templates and all of the templates in Drupal core are n templates folders in or in the templates folder inside of a theme or inside of a module so they're a little bit easier to find there in less locations so here's an example this is no dot TPL dot PHP this is what it looks like on Drupal 7 got this same template on Drupal 8 in twig looks like this so it's not radically different but it is easier to read all those print all the word print isn't in here I mean if you notice I always have to say print this print that PHP print all the time it kind of eliminates that but most of the same functions are there you can do conditionals there's some if in this stuff here and you can do no it doesn't show it here there's not one here but you can do loops and things like that into it so it's just something you can probably pick this up in a couple hours it's pretty easy transition another change ie8 is not going to be supported by Drupal core in being Drupal 8 at least not entirely goopy you know it may work for some pages but system-wide it's not going to be supported so that means it's IE 9 plus is required for Drupal 8 so this is going to make themers lives a lot better but certain clients who need to support Rupali may have to think about how they're going to you know whether Drupal 8 is going to be sorry need to support ie8 will have to think about whether Drupal 8 is a good choice for them if they still need that that kind of backward compatibility they may have to add that backward compatibility or or test see exactly which things are not going to work on Drupal 8 alright module developers um this is where the bulk of the changes and the bulk of the sort of controversy of Drupal 8 comes in pretty much the entire underlying Drupal code has been rewritten in a new style this in the new language almost it's a different sort of flavor of PHP and so module developers have a lot of work to do to get ready for Drupal 8 here are a few of the things that have to be sort of learned or re learned in order to do development on Drupal 8 you need to learn about PHP 5.3 and which in in the object oriented approach of that's available as of PHP 5.3 this includes namespaces and at the moment PS are 0 which I'll talk about a minute dependency injection annotations certain symfony components Yamma which we already looked at and the fact that some of you are some familiar hooks and have been deprecated or removed so after we learn how you do certain things in Drupal 8 so let's go through these and talk about and I'll just sort of show the differences I don't have all the time in this particular talk to really do a deep dive I do have more links into blog post and documentation if you go to that main the main web page URL for this talk which I'll show again at the end of the presentation where you can do a deeper dive into these topics so first let's talk about PHP 5.3 and object-oriented PHP more specifically so let me show you just an example so here's a form out of the book module and I've zipped up the actual code but we can see the function signatures for book admin edit and if your module developer than you know the validator the validation function for that form is going to be book admin edit validate and the submit there's going to be book admin edit submit all right that's a format that all module developers should be familiar with that's how it's been for several Drupal versions this is what that same form looks like in Drupal 8 now it's a little bit it's a class and there's a lot of functions here a lot of methods here in this class but actually it's these right here these three that's sort of a match up to the old ones so we have a book admin edit form class that extends form base and if you know object-oriented programming that should make sense to you if you don't this is an example where you're going to need to learn than that these three functions take the place of the other three functions we just looked at so we have build four and validate form and submit form and I don't have to preface when I'm working in this object-oriented style I don't have to preface my method names with the module name all the time because I'm inside of a class I already have this sort of name spacing from being with inside this class so that I actually think that's a big win because that's a real annoyance having to put like your module name in front of everything all the time once you get inside this at least four forms it looks pretty much the same this is one area that I think we've got off pretty easy here the form API is similar as you can see all right namespaces in PS are 0 so in Drupal 8 everything is object oriented and every all of your code is put into or not all of your code that's sorry much of your code let's say is put into class files now those class files are split out so when I looked at that form a little while ago this one class just has this one form in it and I think the book module has like four different forms in it so that would be four different classes and four different files so if you've worked with Drupal before you know when you break things out into like a dot pages includ or edmond including for example you usually have to do some kind of module load include or maybe maybe that will be part of your hook menu declaration but you have to have some way to load in those include files so that the functions can be found in PHP 5.3 you can create namespaces for your classes so in this particular example I'm showing the book controller and it's in a certain namespace Drupal book controller and that namespace can then be used to include a class when it's necessary and you can actually see that happening down here these use statements are sort of the flip side so this namespace declares that this book controller class exists in this namespace and then these use statements are bringing classes that are are specifying the namespace for certain classes that need to be included and there is a symphony component that's used at the core of Drupal 8 that will auto load the dependencies by sort of reading through these use statements and it will auto load the things that you need now in order for that to work we're using the PS Drupal 8 is using the PS r0 standard and that standard is that basically every level of this namespace needs to correspond to a folder an actual folder level where the files in the folder so for example if the class book controller is in the namespace Drupal book controller then that tells me exactly where this class it tells me the name that this class has to have as file name that this class has to be in and where folder wise so if it's book controller Drupal book controller then it has to be in core modules book libe drupal book controller and the file name has to be book controller dot PHP okay if it's anything else and this autoloaders not going to work so there's two things about it one you have to learn okay I got to make sure these things always match up the second thing is that with the PSR zero standard we have a lot of nested folders all right so between the two things of sort of splitting up by your code into individual files and having to sort of nest them down into a lot of folders in order to keep your namespace clean there's a real explosion in the size of modules or at least their apparent size the code size is probably similar but there's a lot more files a lot more folders so here's an example of the book module for Drupal 7 which is actually a fairly big module comparatively I think it has something like 13 files this is what it looks like on Drupal 8 okay it has something like 30 files and there's a lot of nested folders here's that same sort of tree that I was just showing live Drupal book and then underneath your form controller access there's a lot of nested things under here so some people you know this is sort of more confusing there's a lot of folders it's kind of annoying when you first look at it sort of shocking to see the difference personally I like this better I know that it looks more verbose and I'm probably going to have to make a lot of extra folders but what I do look about it is all of these files are really doing one thing versus like okay so that those forms that admin form might have been in a file I think it's probably in book admin Inc but they're you know there might be another admin form in there so maybe two or three different forms and they're validators and they're submitters all in one file that's not going to happen here okay I've got like book admin edit form that file does one thing it just handles that form same with the book settings form or the book navigation block this so if I want to find out where the code is for the navigation block it's it's really obvious now I don't have to dig or search through sort of all these other files so personally I like it but it is definitely more verbose okay routing so when I talk about routing we're talking about you know time hook menu basically tying a specific URL to a some piece of code that executes in Drupal 8 there the underlying routing system is using is now built on top of the symphony HTTP routing components and hook menu is actually been split into two pieces or what used to be hook menu in Drupal 7 so hookman used to do two things it used to declare actual URL patterns that would correspond to certain code that would get executed okay so you would type in like the well you would have like items and you would have the actual path in there let me just bring up the here's book menu so like here right here you have items and then this is your actual path sometimes the path might have a wild card of some type in it like this and then you would say okay so this URL pattern this particular code gets executed whatever is in the page callback now this has been split into two this in Drupal seven you could also say in addition to the URL I also want to display for example a menu local task that means I want to display a tab so you had sort of two functions happening with this cook menu you would declare the URL pattern and also declare if you wanted some visual representation within the system those two functions have been split apart into bite the function of designing or defining URL patterns and what happens when people go to URL patterns to those URLs is in this routing dot yml file so this is an example again from the book module this is book dot routing demo and it declares these Pat URL patterns and then this controller is actually the this is this takes the place of sort of the page callback alright and notice that there's some some nice shortcuts in here like if your page callback used to be Drupal get form like for example back here I think there was example right this happens a lot where your page callback is Drupal get form and your page arguments is the particular form ID there's a shortcut here for that we can just say that you're passing it to a form so you can declare those routes there and then there is still hook menu in Drupal 8 but it is only used for visible sort of menu it's only it's only for visible menu routes and - and to give sort of these titles any sort of visible manifestation of the route so things that were strictly menu callbacks probably are not going to be in hook menu anymore and these hook menus actually will reference back to the URL patterns so here's an example route name book admin and here's that route defined in the mo file book admin alright now there's a lot more here I'm really glossing over this probably to the point of almost making mistakes here on what I'm saying but there's more information in the blog post linked on the website dependency injection this is another topic I really don't have enough time to go through dependency injection overall what it means is that if you rely on some if your code relies on some other subsystem of Drupal it should not be hard-coded to the particular implementation that ships with Drupal 8 and it should be flexible in indesign in such a way that it it says i need certain resources and i need those to be given to me and then i'll use them so for example a database connector configuration manager translation service i need to be able to translate strings i need to be able to store configure store and retrieve configuration i need to be able to access databases instead of hard-coding that - like DB query which is a specific function in a specific file you're going to say I need a database connection service I need a configuration service in order for this code to run and then you're going to allow sort of the Drupal system to give that stuff to you at runtime and the reason for doing this this is definitely way more complex this is probably one of the most complex changes in Drupal 8 the reason to do this I guess is really three the main one is it keeps your code decoupled okay so you're not dependent on a specific function in a specific file that decoupling allows you potentially to replace subsystem so imagine if you want to replace the database subsystem with one that uses MongoDB that should be possible and can trip because if assuming that everybody uses dependency injection like they're supposed to you should be able to sort of replace that and then you know modules will just say yep I'm going to talk to the database connector service and it should work if assuming that the new replacement works correctly and the third reason sort of builds on that is when you can replace these subsystems it also makes a lot easier to unit tests because you can instead of having to bootstrap an entire system entire Drupal system in order to test one class or one piece of code you can create some mock objects let's say that I have a piece of code that only needs two services I could potentially just generate those two services or generate mock versions of those two services hand it to that code and then unit test that code without bringing in potential bugs from the rest of the system so it makes it much easier to do unit testing so if I just show a quick example of this here here is the book module again it declares for services and the they are declared in book services that yamo and I'm not going to go into the details of all this but more than one thing I do want to point out is that let the book manager service has four dependencies that's what these arguments are here it's in the class book manager it has four arguments it needs database connector and entity manager a string translation service and a configuration factoring something to store and retrieve config from and that ends up mapping over here's the book manager class that ends up mapping over to the constructor for the book manager class so that here it's database connection entity manager translation interface config turi so when somebody creates a book manager that should be sort of handed in well or sort of retrieved from the drupal system whatever the current one is and then brought into into this particular class which can then be used okay so like the translation service can be used in the way that the T function used to be used the connection can be years like DB query config can be config file can be used kind of like variable get and variable set used to be in Drupal 7 alright there's way more to that topic so please go on the website look at the details next thing annotations annotations the best way I can describe them is there a type of code that you write in documentation in your class comments you can declare certain properties with these annotations and this works for several sort of plug with well for several plugins our plugin based systems in Drupal 8 so here's an example of and it takes the place of a lot of info hooks so in Drupal 7 if you wanted to declare a new block you would implement hook block info and you would give it information about the name or some ID number the Delta of that particular block in Drupal 8 you do that in the class comments and you do it in a special format here I'm showing it to you where you declare that there is a block it's got a dis ID book navigation this label is sort of what what it shows up in as in the interface when someone is on the block interface and then down here in the actual class you would have whatever the rendering is for this and if it had settings or things like that this works for other plug-in systems too so for example if you're writing views display plugins this is what it looks like again this used to be in in an info hook or but now it's in this sort of plugin annotations there are several Symphony components that have been implemented or started they've been sort of either used as the underlying system of Drupal 8 I think we've actually gone through most of these or at least touched on where most of these come in so I'm not going to go through them again but you may from time to time encounter situations where you have to deal with these subsystems directly so you may have to learn something about them you know maybe not for the simplest modules but for more complex modules you might there's also some additional non Drupal components that are not Symphony either that are in Drupal 8 such as composer for dependency management guzzle which is an amazingly awesome HTTP client this guzzle takes the place of like Drupal HTTP request or curl it allows you to pull data out of other web services but it's got a lot of features and it's super easy to use it's really great ascetic is for asset asset manager it does like CSS and J's segregation I also think it can do some things with image resizing PHP unit for testing and PS are log to do consistent logging because now that we have all these different components that are non Drupal and we have Drupal itself we need some consistent logging framework to route all the error messages and stuff through our debugging messages and so with all these changes I would say that this really makes strupo a a modern PHP app this style code is definitely much more sophisticated but it is sort of you know it is the major standard of new PHP work that is being done today and so new projects starting today people don't have a legacy code base and so by adopting these new coding standards this object-oriented style and dependency injection and all these things it's going to be easier for Drupal to work with the rest of the PHP community we can integrate their projects like we did with symphony and we can also contribute back work back out to the community without sort of having that translation where we have to take work that other people do and turn it into like a Drupal compatible something and vice-versa so my game plan for developers if you haven't started looking at Drupal 8 you need to nail it there's a lot of stuff to learn and you're going to want to get started with it if you're not familiar with object-oriented programming that's definitely true that's going to take a little while to learn and so you're you know you want to get started on that if you have modules that you either on Drupal that or if you have our own private modules that you're using in your business start trying to port them you know see see how hard it's going to be to make them work on Drupal 8 but realize that if you start to work on them import them now you may have to redo it because they're still changing a lot of things about your pilate's so it's possible you have to do it again but you're not gonna have to redo the whole thing but you just realized there may be more work to do if you one reason to port them now is there's still time for the core developers to change some of the developer experiences some of the AP is that are available and examples and documentation and things like that so if you try to port them now and you run into problems you can give that feedback to the core team and then they might be able to make it easier for both you and others and if you happen to be somebody who knows a lot about dependency injection and object-oriented code and everything then please help other people because it's going to be a tough transition for people who have been working in Drupal for a long time because it maybe haven't sort of seen what's been going on in the rest in the larger PHP community so if you are able to work in these please help bring some of the other Drupal developers along all right so the big question everyone wants to know is like what's the time line that's going to be ready so I took to the beginning Drupal 8 development started March of 2011 feature freeze was in February of 2013 they're supposed to be an API freeze in July of 2013 but that didn't quite happen I mean there's a lot of code that's changed and so the dates have started to slip here as and especially because some of the developer experience is real rough right now it's hard for new developers to make this transfer for Drupal developers to make this transition to the new framework so there's some reworking of some of the API and cleanup and trying to enhance the developer experience and so um I pulled this graphic off of drupal.org this is we're right now in this alpha release stage so there's been a couple out four releases they'll probably be one or two more at least and API is still slushy it's kind of you know it can still change but it's semi-frozen it'll only change if it's important which is why it's a time when you can probably start to pour some of your modules but maybe not all of them the okay so he yeah I just went through that so DX improvements are underway we're factoring ongoing also there's a new initiative that just came up a couple weeks ago to get migrated into core can make it easier for people to migrate their sites from my Drupal 6 or 7 up to Drupal 8 to sort of move to content and stuff that's a brand new initiative that's sort of coming in here last-minute I've been told that it's definitely getting in but um it's sort of a scramble here at the end so it's kind of it's sort of outside of the normal sort of API slushy frozen Ness because it's it's in really active development right now um so how can you help right now you can fix critical issues in the issue queue this might be a tough if you're not a core developer already this one's probably going to be hard for you to do but if you feel up to it that's that's out there there are definitely critical issues that need fixing um something that might be easier if you're a developer you can review you can review and test patch it's actually you could do review you could test patches even if you're not a developer reviewing patches you probably need to be a developer but basically just people have posted patches that say that they fix a bug you can install Drupal a try to run the patch see if it fixes a problem that it's been identified reroll or fix failed patches this is a big time suck for a core developers where you know somebody post a patch it works and Drupal 8 then like you know a week or two goes by Drupal eight that patch no longer works because the code on Drupal 8 has changed so much in that two-week period and the patch needs to be rear old that's a really pretty simple way that you can get in there and like you know so to get some familiarity with the system without needing to know because we rolling a patch just basically means moving the pieces around to their new locations because this the code is shifted usually a bit like up and down documentation so web chick has posted a documentation battle plan as I said there's a lot of changes so people are going to need a lot of Doc's so you can help range from those knocks here's the URL for the battle pan and as of today they were still a few Twigg conversions left but time you see this that that may no longer be the case but there are a few template files and things that still need to be converted to twig and migrate initiative is a new initiative still needs a ton of work so there's actually quite a lot of opportunity there if somebody wants to jump in how to get started best way go to core mentoring hours if you go to core mint if you've never done core development work go to court mentoring hours it's on IRC and um a core developer will help you find something to work on because that's actually one of the most daunting things if you go to the issue queue there's like a lot of really smart people having arguments about really complicated like detailed technical things and it's really hard to feel like you can jump in there if you've never done this before so if you go to core mentoring universe those people will help you find something that is appropriate at the very least they can tell you you know if a solution has been accepted because a lot of times we'll see argument back and forth about it they can give you something to work on and help lead you in the direction of how to do it you can also start upgrading your module so there is a Drupal con Portland session about operating your modules it's linked on the website with this presentation and the pants module is an example module that has also that has been upgraded to Drupal 8 it's part of the Drupal you know it's referenced in the Drupal con Portland session alright so the upcoming what's when can we expect Drupal 8 to be released so right now we're in that API phase threes at Drupal con prog said that he hoped to have beta releases by the end of 2013 and our C release candidate one release sometime early in 2014 so the release will be when it's ready hopefully sometime in 2014 I think I think safely we can say it'll be sometime in 2014 but um you know it's not going to be January it's probably going to be sometime middle of the year ish somewhere in there so when can you as a regular user think about using Drupal 8 if you have a simpler site like a blog or something you might be able to do a pretty soon after release now that views is in core if you didn't get about a blog it doesn't usually need a lot of stuff other than a content type in of you and so you might be able to use it whenever comes out may be relevant year um if you have more complex sites like community sites if you're doing forums and groups and other kinds of things and you're definitely going to have to wait a while you know typically it's about nine to twelve months after Drupal is after a Drupal release for module developers to sort of get up to speed now you know it'll be interesting to see how that changes with Drupal 8 there's a couple things here first fuses in core which I would normally say would sort of make it easier for module developers to get their module upgraded however there are so many coding changes that have changed underneath that that's going to be working against them so it'll be interesting to see if this 9 to 12 months holds or if it gets shorter or or longer and so that's it that's triple 8 what you need to know I'm Wayne acre again the link for where you can get a whole bunch more information about all these topics it is here when acre Commons that's triple 8 thanks for listening
Info
Channel: DrupalTutor
Views: 34,758
Rating: 5 out of 5
Keywords: Drupal (Software)
Id: l98dVUABD4w
Channel Id: undefined
Length: 64min 48sec (3888 seconds)
Published: Wed Oct 16 2013
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.