 Good morning, so it's 10.45, so I'm gonna get started. This is awesome, so we packed the room, excellent. So welcome, this is my microphone. They wouldn't give me one that would move around, so I might move away from it, which is why it's really good that you're all here, because you'll be able to hear me. The recording, I might go in and out. So bonus for attending the session in real life. My name is Ryan, I come from the Symphony World, obviously, you're in the Symphony Room. You are not interested in Symphony, then you're in the wrong room, but hopefully you are. So I come from the Symphony World, I work on the Symphony Documentation, which as a Drupal developer you might be looking into. If you like it, I would appreciate you telling me afterwards, and if you don't like it, I would appreciate you leaving directly afterwards and not saying anything. Very fragile, okay? Well, one time I was at a conference and I went up to a table with some strangers and said, oh, what do you do? And they said, do you use Symphony? And I said, oh, what are you thinking about? And they were like, oh, we love it, it's just the documentation sucks. I also write it for at KAMP University in Sensio Labs and Blackfyre fanboy slash evangelist. If you haven't heard of Blackfyre before, it's a sweet, super fun, awesome profiling agent for PHP. You can actually go file your production sites, and they're doing demos downstairs every now and then. I just watched a demo and it was super fun. So check that out. It's one of those things where it's fun to use and also productive and helps you, but it's fun, so it's good and nerdy. And most importantly, I am the husband of the much more talented Liana, who is not here. She's always here, she's not here this year. This is usually where we like, I have you guys wave at her, or I say that she likes hugs or high fives, or she's a beautiful singer or something like that. Something where you guys can embarrass her later. She's not here because she's at home with our six month old, Beckett. Oh, you guys are the best. Oh, but don't worry, I have more. There is he, this is cool. Yeah, he has a mohawk. He lost all his hair around the sides, and so we just ran with it. We're like, okay, let's make the top taller. And there he is again, looking confused. And this is really him. We have this one framed in our living room. And on the bottom of the frame, it says something like, love you more every day. And it's our way of keeping sanity, because having a kid is hard. Hundred people have kids? Yeah, I figure, okay, bless you. It's a thing, isn't it? Oh, it's awesome. Okay, so enough of that. So let's talk about symphony, symphony components. What is symphony exactly? Symphony is the reason you had to wait five years for Drupal to come out, right? Sort of. That's part of it. So symphony actually is just a collection of small independent libraries. We call them the components, so you'll hear that word use, the components. When you think of a component, think of a directory with some PHP classes inside of it. No magic, no configuration files, it's just literally, if I give you a couple of PHP files, you'd be like, cool, I'll start using them. That's what the components are. Drupal actually uses 100% of the symphony components. Oh wait, it's less than that. It's most of them, it's the majority of them, it's about half of them. So in your Drupal project, actually you only have about half of the symphony components to solve. Which means there's a whole other half that's just sitting there on the menu should you have the problem that can be solved or helped with one of those. And even more than that, there's about 26 symphony components included in a normal Drupal solve, how you do it. Even though Drupal is using symphony, but you might not be using symphony. So it's kind of like, there might be some things you're leaving on the shelf, like your solving problem, A, B, and C, and there might literally already be code in your project that you're not making use of. So that's what this presentation's about, is like, hey, let's run through some of those fun things, kind of like put light bulbs on for some of the problems that you might be able to solve in the future in like, honestly, a more fun way. All right, so how did symphony get into my project? Who snuck it in there? When you download symphony, or when you download Drupal, sorry, or however you're gonna sell Drupal, Josh, whatever, symphony is already sitting there, it's inside of your vendor slash symphony directory. So it's like all of those 26 components are already sitting inside of there. Who put them there? Well, technically Drupal put them there, so you download them and they're there. But the real answer is Composer, which is PG Pack Manager, which I'll talk about in a second. So already out of the box, I just want you to know those 26 components are sitting there waiting for you to use them. But as you'll see in a second, if you want one of those other 25 components that isn't there, you can very, very easily get them into your project. Drupal 8 didn't require people to use Composer to manage their dependencies, but they gave you everything you needed so that you can do that immediately if you want to. So it's very, very easy to start calling new stuff into your project, and I'll talk about that. I was gonna say, who put that there? No, I forgot about that slide. That was the last second slide. There we go. So another way that you can see the things that you have inside of your project is, again, VIA Composer is a Composer show, man, not many people know that. So normally when you use Composer, you're using Composer to download things from your project, but you guys are a little different in Drupal because you inherit a bunch of stuff, so you sort of have a reverse discovery process where you're like, I have Drupal, I already have stuff in my project, what is inside of there? So this is actually not the entire output, but if you guys run Composer Show inside of your Drupal project, it's actually gonna tell you, like here's all the menu of things you already have sitting in your project. All right, so let's go through a couple of the individual components. So the names of the components are always like symphony flash, something else, and in a second I'll say, we'll see how to install them. So there's one called symphony slash debug. So let's build a block here. So we have our build function, I'm gonna make an items array, and then we're gonna put those into an item list and life is good. Who can spot the mistake? I don't think I could. Good, good, good. Drupal doesn't have a slash. If you don't know what that means, like you'll see in a second. So if you stare at this, it's hard to see what the error is. Don't worry, because if you refresh the page, Drupal will tell you. Now we all know what the mistake is, right? Of course, that's if you don't turn logging, I realize if you turn logging on and things like that, then you get something that's very, very attractive. At least it tells you where the error is. It's a little rough on the eyes, but it takes care of it. So if you go into your settings.php file, or your settings.local.php file, if you wanna have a local.php file, these are the two lines that you need to add inside of there. So use statement and debug, colon, colon, enable. And as soon as you do that, your errors look like this. Right? It's not the end of the world, it looks better, and that's just one line of code. It's just two if you count the use statements. So this is exactly the type of thing I'm talking about. Like these tools are just sitting there for you. And if you know about them, you're like, awesome, I'm gonna add that one line, and all of a sudden my errors are gonna look a little less terrible. So there, there's the slash they were talking about. Items equals slash drupal, because that's at the root of the namespace. Easier to catch once you actually know what line is happening on. So wait, wait, wait, hold on a second. Did I need to install symphony slash debug, or is that one of the ones that's in my project already? I don't know. But the way you can be for sure, and this is actually the process that I would recommend going through is, I want to encourage you guys, so let me like back up here, philosophy of the talk time. I want to encourage you guys to embrace tools from symphony and tools from around the PHP world. To do that, you will need to use Composer, which means step one, you'll need to download Composer if you haven't done this before. Composer is a far file. How many people are familiar with far files? That was like most of the room. If you're not, a far file is like a single PHP file, it ends in .phar. It's a single PHP file that you can execute like a command. So if I give you a far file, you can say PHP space, coolstuff.bar, and like things happen, it's all packaged together. So Composer's just a far file. You download a single file. You copy these four lines to your command line, but this is like fanciness for downloading a file called Composer.bar. And often times when, this is something that when you're starting with Composer can be gotcha, when you run those four commands, you get a Composer.far file, but then you're kind of supposed to move that into like a user local bin and rename it to Composer. Because what you'll see on the web is that people will say, oh, you want to use Composer? Just say Composer space install. And if you do that, and you've only downloaded the Composer.far file, then you get command that file. So, you know, kind of transit then. You don't have to do that, if you just downloaded the bar file, then you would say phbspacecomposer.far install. So anyway, so one of the cool things about the way they did Drupal 8, and remember, I'm coming from the symphony side of things, so I'm starting to look into Drupal, especially Drupal 8.3, and they're like, yeah, they're really starting to organize things in a really nice way. When you download Drupal, your vendor directory is 100% populated with symphony and all these other external libraries that you need. If you want to, you can rm-rf that directory completely and then run Composer install and it will put all of the back, which means you actually don't need to commit your vendor directory to your Git repository. You can add slash vendor to your .gitignore and that's safe. And the reason it's safe, and this is, I'm not gonna tell the whole story because this is not a Composer talk, is because there's a Composer.json file at the root of your project, which specifies what you need in your project. And it's yours to modify so you can add more stuff to it. Out of the box, this is not the whole file, but the important part of the file is the require key that says what my project needs. And you'll notice it doesn't have a lot, it has like two things, you're like, that looks a little short. And the reason is there's, you have a Composer.json file at the root of your project and then there's also a core slash Composer.json file and this has all the stuff in it you'd expect. This is actually only about half the list. My cherry pick can show the symphony stuff. So what Drupal does, it's kind of unique, but it's kind of cool, is when you run Composer install and say you basically ask Composer to download your dependencies into the vendor directory, it reads your Composer.json file at the root and your core slash Composer.json file and merges them together. And the reason it's done this way so that Drupal can use Composer to like say, we need all this stuff and they kind of want you to not touch that file. So you can actually, there's a different way to set things up where you have full control. But they don't want you to not touch that file. But then you can touch this file. So it's kind of cool. So you get all the stuff you need, but this is your file free to edit. So that's where the magic is coming. Like why, I don't see symphony in this list. Where's it coming from? All right, so if we want to use symphony slash debug and we're not sure that it gets installed or not, I mean there's ways to check. The safest thing to do is just to run Composer require, that's the way you add something to your project and then the name of the library symphony slash debug. Normally, you do not need to specify the version. Notice I say symphony slash debug colon karat 2.8. So all these weird symbols with version constraints and Composer. Karat is basically a fancy way of saying I need 2.8 or higher, but not 3.0. So normally when you run this you just say Composer require symphony slash debug. And you can do that in your project, you might get an error and if you do use colon karat 2.8. When you run Composer require without a version, it's really nice because Composer goes out and finds out what the latest version of that library is and then it solves it, tries to install that. The problem is that the latest version of the symphony components are 3.2 and right now your goal only works with 2. something. So in the future you might be able to run, so you can run this without the constraint but like if it has an error then you might need to say no, I want 2.0, don't try to install 3.2 that might not be compatible with my project. So in this case you can see there's not a lot of output because in fact we already have symphony slash debug in our project. But if we did, you'd see it actually download that into our project. The nice thing about this is it did update our Composer.json file. So we didn't need to do this stuff but now we explicitly say we need symphony slash debug. So in the future for some reason the group will stop relying on symphony slash debug. It wouldn't just disappear from our project because we specified that we wanted. All right, so let's go through a few other of my favorite symphony slash finder. How many people have written functions before to like look through the file system and like look through directors recursively and list files and things like that? Yeah, yeah. It's one of those problems that comes up every now and then and you can't remember how you solved it last time and it's annoying. So symphony finder is one that solves that. It's super fun to use. So let's suppose for some reason we want to find all of the core template that's twig files that are over one kilobyte in size and sort them by name. That's it. It's about those five lines of code there. And you can see down here the finder object you just loop over it and that's just gonna return all those files. And there's other things this thing can do. It's super bomb. You can view custom sorting in other ways to kind of filter out your files. There's even a method to ignore version control files. So there's dot get things in there. It doesn't grab those. All right, so awesome. So this is cool. So when I loop over the finder, what is file exactly? Is it like a file name? Is that some sort of an object? Well, let's find out. And actually before I find out, I wanted to show this. See the before and after. Just to highlight finder actually works with any valid stream. So you can actually do this over it. Of course if you're scanning like 100 directories over FTP, no matter what you do, you're not gonna have a good time. But you can do that. In fact in the documentation, we also show an example of using a stream wrapper to create a stream to S3 and then actually use over a bucket. Same thing. If you do too much work over the network, it's not gonna do that fast. But it's really, really powerful. All right, so anyway. So back to this one. We wanna find out what that file thing is. So let's talk about symphony slash var dumper. Another random component that's just sitting there waiting for you to use it. So now, if I have the var dumper installed, which you do inside of, actually that's not true. No, you do not have inside of Drupal, thank you. You do not have inside of Drupal 8 by default, but if you install develop, develop actually requires this. So again, it's one of the things where it's like, do you have it in your project? I don't know. If you're not sure, just try it or try installing it. So this guys, as soon as it's installed, we have a flat function called dump. One of the few times in the kind of PHP package world where installing a package gives you a flat function, but it's just for debugging. So as soon as we do that, we refresh the page. This is what our block looks like. So you guys have something similar with like develop with like kint. You know, this is kind of like a different version of that. They do similar things, but not exactly the same thing. It just gives you really beautiful output. It takes care of like the recursive dependency problem. And as you can see, the first SPL file info I've collapsed. It actually dumps with a bunch of JavaScripts so you can collapse and open up things at a deeper level. It's really, really fun. So this answers our question. It's an SPL file info object. Actually, that's got a longer class name. If you hover over that, you'd see the full class name of that class. So awesome. So now we can go back here. Now that we know this is an SPL file info, I'm gonna do a little inline documentation because I'm absolutely obsessed with getting auto completion of my editor. Can't change my editor that that's an SPL file info object. And now I can, you know, get the file name and get the file size and kilobytes and life is good. And lo and behold, we have in about 10 lines of code prints out all of the twin templates from the core themes. That are greater than one kilobyte size and ordered that by name. All right, so let's keep going. Symphony console. This might be the most widely used and plugged symphony components like across the PHP ocean if you will. So the console, Symphony console is all about doing things from the command line, making command line applications. So we are no longer in Drupal. I just created a command.php file just at the root of my Drupal project. Cause I need to do some scripting. I need to maybe do some database imports. I just wanna be able to hammer them out in PHP code. And I'm gonna output some things to the screen, maybe some progress in the screen as we're doing it. So this here actually creates a, actually I'm gonna show you what this does first and then I'm gonna come back to the code. What this allows me to do, remember this file is called command.php, is now I can say PHP space command.php and I can say greet which is the name of the command. Here you can say app arrow register greet. And then I can pass in an argument, Ryan, and it comes out and prints that out. Or I can pass a dash dash yell option. Again, back here you can say to add option yell. And in my code here that down at the bottom I'm actually using that to str to upper that thing. So if you've ever created like a shell, a script or a pg script, you can use like the rb stuff and you've forgotten that the zero index is actually the name of the command. You have to go to one index for the first argument. That's the stuff it solves. It's really easy to read off of arguments. Really easy to read off as many options as you want. Drupal console is built on top of this. So that's why you get all the nice arguments and options, that's why the coloration is really good inside Drupal console. It all comes from Symphony console. So this is literally the entire file to get that done. So again, the important part is there. That's the name of the command. There's our argument down below. You can see it says name equals input get argument. So I'm getting the argument. And then there is the option yell dash dash yell. And again below down there I'm saying input arrow get option yell. So you're kind of setting up what your arguments and your options are. And then inside of the callback function you're just grabbing that and doing whatever you want. We also have, actually I'll show that in a different slide. If you just run psp space command.psp without any arguments it's gonna give you this help thing and it's gonna tell you the available commands at the bottom. Because right now we only created a greet command but the power of this is that you can create many commands. You know command.psp to do this, space to do that, space to do this other thing. So we have our greets and then there's a couple built in for help and list. This is list here. So as you like what commands you got. All right so let's kind of start combining things then. So we're gonna use our console to actually do the same thing with the templates, list all the templates. So in this case I've decided to have one argument called dir. So what directory do I wanna look in to find templates? And inside I'm gonna create the same finder. This time I'll say finder in and I'll say input get argument dir. And it's gonna look in whatever directory I've passed the command line. And then down here we're gonna do the exact same stuff as before, loop over the finder. Except this time we wanna print it out. We wanna print the results out. So we're gonna use output arrow right line. The cool thing about the output object is that it has built in coloration stuff. So you can see here I wrap it in comment and info. There are a couple built in blocks like that that are actually gonna color the outputs. There's actually something called symphony. There's an object called symphony style, which you can actually create inside of here. And that gives you all kinds of other methods for creating like big caution blocks and like notes and things like as a bunch of built in styles because you can basically color things however you want using this. So in the output you can see I get the yellow and I get the green for the comment and the info stuff. Well wait, there's more. Because once you're inside of here, like okay. So getting the arguments and the options, that's actually really powerful. That's kind of a pain in the butt to do. The coloration is nice because you know honestly when we run things in command line the color comes out, it just makes us happier. This is good. But there's a number of built in tools inside of here. The two I'm showing here are the table object and the progress bar object. So if you need to print things out in a table, you can actually use the table object. I'm setting the headers on that file and size and then as I'm looping over my finder I'm actually adding columns to my row. And as you'll see in a second that's actually gonna print this out as a nice clean table. I'm also using the progress bar. When this first came out, I was like I need to find a problem where I can use that on. I was like this sounds cool. You can use the progress bar and I'm saying the second argument up to progress bar, the count finder is basically telling you how many increments, am I going over 100 things? So as you loop over them, I'm saying progress error advanced and it's just gonna take that thing up. So at the end, oh, there's what it looks like. Up, up, up, up, up, up. Put a little sleeve in there so it looks interesting. There we go, and then print it out at the end. Cool? And if you Google for it, there's even a blog post where you can turn the little arrow icon into like a little beer icon and it goes across, you know, whatever. It's all kinds of weird coloration fun things you can do. Because probably if you're using the progress bar you're already wasting time. I don't know if this will go the rest of the way. And then this is the last one I wanted to show is we're in raw PHP land, we're not inside of Drupal. But you can, and I do things like this in Symfony, you can boot up Drupal inside of there and then do works, in this case I'm actually effectively booting up Drupal's container. My phone is actually ringing, it's never happened before. booting up Drupal's container and then I'm gonna grab the database service and then I'm gonna run a query on that. Oh, and once again, I don't use the database service very often so I can't remember what the query function returns. So let's use the dump function from var dumper and when we run this, we actually get really, really clean output to the terminal this time. So the var dump for the dump function actually detects its environment and then decides whether it should dump HTML or it should actually dump really, really nice coloration to your screen. So it's a really nice way to dump things on your console. All right, next up, Symfony file system. This one's really small but awesome. Symfony file system is actually a single class and it just has a few functions for doing annoying things on the file system. For example, like making a directory is annoying if you have the recursive problem you know, wanna create like five directory feet. So if you make there, it takes care of that. Mirror is kind of a cool function. It basically copies one directory to another but almost more like rsync. You know, it's like if there's stuff over here, there's already, if the destination army exists, it's just gonna synchronize that. We might delete some files over here and it'll add whatever files are missing. And you can see the components are actually working together. So if you wanna do a chmod, you can pass chmod and you can pass it a single file or an array of files or you can actually pass it anything that's iterable like the finder. So we can actually create a finder and tell that to find all files that start with the word block. So this is gonna chmod just the block star files inside of that directory. There are, one of the things that the file system does not do on purpose is this is not a file system abstraction layer. How many people have heard of fly system? Okay, a few people, yeah. Fly system is a PHP library. It's not a symphony component. It's a really nice PHP library that gives you file system abstractions so that you can kind of create a file system object and start reading and writing files. But behind the scenes, you can figure that to go to a file system or S3 or FTP or something like that. So that is also a great tool. This is all about actually writing to your file system like your actual local file system and doing things there. Symphony slash process. So many good things. I use this all the time. If you need to run, if you're using shell exec, that kind of thing, don't use it anymore. Use this. This is that, I haven't used shell exec or those other PHP functions. I don't even remember what they are in years because of the process components. So in this case, I'm gonna create a new process object. That's gonna be the command that I wanna pass at the command line. That's why I wanna actually run the command line. I can set a time out so that it'll explode if it takes longer than five seconds. There's also an idle time out if you want it to explode if no output has happened after a certain amount of time. And then you can actually run the process asynchronously. So you can say, go run this process, but I'm gonna go do something else while you run that. So process arrow start is non-blocking. That goes and starts it, but your code keeps running. And then once you actually wanna wait for it to finish, you can just use the while process of running to figure out when it's actually finished. Or you can run it synchronously also. There's a process arrow run that will run it synchronously, but asynchronously it looks cooler up here. And the bottom you can see the process was successful or not successful. You can get the output, you can get the error output. You can set signals, you can set like a kill signal to your process. You can get the PID of your process, all the stuff that you want to have with the process is inside of here. So it's just much nicer than using the shell exec stuff. Oh, and that's what that outputs. You weren't, you're from house A, you are now. So make sure you guys install house A and try that. How many people use Ansible? Couple people? Fun fact about Ansible. Does anybody know what I'm about to say? Yeah, what is it? Ansible has house A built in? Yes, Ansible has house A built in. Well, sort of. So Ansible is a tool you use to provision servers. So you run a command and then start installing things and give you all this output. If you install house A on your machine, the next time you're in Ansible, all of its output comes through house A. It terrified me the first time I saw it. I was like, what is happening? Something is horribly misconfigured. SIFI slash lock, this is another tiny library that just solves a problem if you have it. So if you need to do a line of like a Drupal has kind of a locking mechanism for itself. This is kind of just a standalone one. So if you need to lock a file or lock a resource that other things can't use it, this is a way that you can do it. You can store that lock on the file system. You can store that lock on Redis. If you have multiple servers and you can decide that you want to wait for the lock, so the lock requires what actually goes and grabs that lock so that can either fail immediately or you can say, wait for the lock to happen. It's that expiration, all kinds of stuff. So this is actually something that I use in my projects. SIFI slash dot env, does any, I don't actually have it coming out. I wanna ask that, we'll just show it. So in a perfect world, this is one of those, this is like a manifesto about it, the 12-factor app. In a perfect world you're now supposed to store your configuration in environment variables like if you read about it on the web. So instead of having them like in like settings that PHP file or something, you're supposed to read environment variables. Not saying you guys need to run and do this, but like you'll hear about this if you haven't heard about this before. So that's fine. In PHP, that's easy, you can use getEnv and you can read your environment variables from getEnv. Cool, easy enough. Except developing is now a total pain in the butt because you have to like set environment variables before anything in your application actually works. So SIFI has a new dot env component. Like it's super small, super simple and what it does is it allows you to have a dot env file and you put environment variables in there. This is primarily for local development. And now back in our settings.php file, we basically just add two lines. We instantiate a dot env object and then we say go read the dot env file and it's just gonna go read parts of that file and make those available as environment variables. And if you do have the real environment variable set like you should on production then it's gonna use those instead. So on production, you're using real environment variables. Locally, you're reading from this dot env file because it's just a lot more convenient. Oh yeah, teasing a new thing and 8.4 question mark. If this is a little more technical but if you're familiar with symphony services, the service configuration and things like that, you can actually probably in the next version of Drupal using this weird percent env dot percent syntax, you can actually inside of your configuration files basically have it read from environment variables. So in this case, I have debunk equals one there and then down there I'm kind of referencing that. And the reason this is gonna be cool in the future is that you have using containers, for example. One of the three parts with symphony and I think also Drupal is using things like containers that if you change the configuration, basically need to rebuild your cache. And if you want your container to be read only, it gets kind of weird. So with this thing, it actually jumps to your final configuration actually reads get env. So basically you just say read my database host via get env. And if that changes, like the code dynamically is just gonna read the new value without needing to rebuild stuff. Sympathy slash cache. This is another one, so awesome. Again, there's caching things inside of Drupal. This is just a standalone library with like tons and tons of options. So here we're going to get an item out of our cache, whatever that is. We're gonna set a value on it, save it. Down below we can see if that cache was a hit because we might have set like an expiration on it or something. And if it is, we can get the value. This actually comes from PSR. It comes from like there was a new PSR6 kind of PHV standard. Or if you create a caching library, it's supposed to follow a certain interface. The sympathy cache library does follow that. If you don't know what that is, it's not that important, but it's kind of like a new system in case you're caching, this follows it. And of course behind the scenes, you've configured your cache to store on the file system with a database or memcache, redis, wherever, behind the scenes. So yeah, so you have many adapters. You have cache tagging and validation, which is really important for people that do a lot of caching. You have expiration on it and it comes with free cookies. So make sure you take advantage of that. Sympathy expression language. These are so cool. So I'm gonna tell you a story of this being used in real life. So first of all, the symphony expression language just allows you to write a small twig-like expression and then actually evaluate that at runtime. And what it's trying to solve is, well, a couple things, but it's situations where you almost, let me tell the story. So there's a company that's built without symphony. And they're a e-commerce shop and they have lots and lots of custom rules about when certain things should happen and they're constantly changing. Like, if the user comes to the site and it's the first time they've been to the site for 30 days or longer and they have purchased at least three products over a value of $100, then send them an email with a coupon for 10% off. Okay, we can all code that. But these were changing so constantly. They were constantly coding new things and having to go through a whole deploy. So what they actually did is they actually deployed an add-in for their site and allowed their, basically their add-in people to write rules that follow these things using like a little rule engine. Of course, there's a little bit of training to get like the syntax and all that, but they're effectively storing that logic in the database, which is awesome as long as it's not e-tico, but you're e-balling, of course. That's the problem here. So they actually use the expression language and they store things that look like this in the database and then they would actually evaluate these at runtime and you're evaluating them safely. This is an example of what it looks like to actually use the expression language. You create this expression language object down here. You can call it language evaluate and you pass it the expression. So in this case I'm just saying fruit.variety and that's gonna get the variety property off of the fruit object. So if you've been using Twig already, it's very, very Twig-like and it's not cool. There is a couple spots you can actually sort of and yes, no use this in the future in Drupal. There's actually a little known condition option you can add on your routing file. It's not handy that often, but it's actually an expression that's run to check whether or not you route match. So I made a really annoying one here that the route only matches if I add question mark load equals one to the URL. Down here, this actually doesn't work. I don't know why Drupal didn't support it. It's actually explicitly not supported in Central Mile. So it might have just been like a to-do for the future. This one's actually a lot handier. You can, again, this is a lot more technical if you're not super familiar with the services stuff in Drupal 8 and don't worry. You can actually use an expression inside of your service configuration. So in this case, what I'm saying down here is the first argument to my Old Bay Seasoner class, whatever that is. The first argument, what I want you to do is I want you to go and get a service called config.factory, then call the method get on it, pass it Old Bay.default, and whatever the object that returns, whatever that returns, that should be passed as the first argument for my service. So behind the scenes, you can see it's gonna be equivalent to a kind of new Old Bay Seasoner, and then go out and get the service and call this method on it. That one doesn't work in Drupal 8. Somebody just needs to do it, because I cannot think of a reason why that would be a problem. Simply property info, I'm not gonna show this one. This is just, it's like, if you have this problem, if you ever need to like, get information about the arguments, or the methods to a class, the arguments to a method, what return type is this method, what arguments, what are they typing it with? If you're doing some sort of meta-programming and using lots of easy reflections to do that, this does that for you. You just basically point it at a class, you point it at a method, and say, give me all the information about that thing, and it gives it back to you in a really easy to understand way. Simply slash workflow, it's a workflow engine. I'm not gonna go through the specifics on this. It's super fun. You can specify different workflow paths, you know, going from the best one here to say is, the transition's on top, where we go. So you kind of make an action called toReview, and that says you're gonna take you from the draft transition, or draft phase, to the review phase. So it kind of takes your objects like through some sort of workflow. I don't show it here, but what's really cool is you can actually, once you set up your workflow, you can dump it to an image file. And it gives you like the whole, kind of like boxes with arrows going around, and dump out the whole thing visually, which is, you know, that's just really cool that they did that. Simply slash LDAP, you'd have LDAP. In the future, there might be one called symphony slash image, which helps with image transformations, symphony slash UTF-8, which is over my head. I looked at the polar class last night, I didn't understand it, but I suck at UTF-8, so now I probably won't suck at it. So that's a future component, and maybe even symphony slash your laundry. So, the point of all this is, you know, Drupal is using symphony, but that doesn't mean that we are necessarily using symphony. So I want you guys just to be aware of what tools are out there. How do you know what's out there? As far as symphony goes, symphony.com slash components is gonna give you basically a list of all the components, where the documentation is. Again, like, you know, when symphony got brought into Drupal, it changed lots of things in Drupal, and Drupal actually brought in like the hardest, most fundamental symphony components. So when you're learning to your belay, and you're like learning all new symphony stuff, like, it can be difficult. Like, this stuff is pretty challenging. All the stuff we showed is not that challenging. These are all like, really straightforward, just classes that have a couple methods on them. They're just tools that are sitting there for you. So this is not kind of the hard stuff in symphony. This is the low-hanging fruit in symphony. Also, when you use Composer, of course it's not, there's not, symphony's not gonna be all anything out there. So packageist.org, you've probably seen that before, that's the main repository for Composer, that has, let's say in here, I don't know, I don't know, hundreds of thousands of packages on it that you guys can install via Composer. And side note, Composer loves your crappy legacy project that you're forced to work on every day that's built in Drupal 4. There's a matter of Composer. Composer's just downloading classes. So if you have to choose to get a code, there are literally zero classes in your code base that all compares. You can still bring a symphony finder and use it. It's not, it doesn't need to integrate into your framework in any way. It's just a class. So you can just bring that class in and use it. But I did a screencast once where we were like teaching Composer. And just to prove a point, to teach Composer, we installed it into Drupal 6. I was like, if it can work in Drupal 6, then it can work anywhere. So you have Drupal Modules. That's tool number one. Drupal Modules are amazing. I wish I could use the Drupal Modules sometimes in my projects. You have about 50 symphony components and you have every other PSV package on the planet. So go build something ridiculous with lots of tables and progress bars and find your grad and then take a screenshot or something and do that to me. All right, thank you guys very much. Buy any of those libraries or anything else. How did you get your color scheme? Which color scheme? The one you used for your code display. Which one's that? Oh, it's actually text mates. But I don't remember exactly which theme it is. Text mate has a, at least text mate two has a, thank you. If I hold down all the keys on the left side of my keyboard and if I press C, it's like command shift alt C and copies it as like RTFs, I can paste it in my slides. When you had your job along, but you were saying you were printing out the object, what's the bar number? Yeah. When you were using your bar number, where does that display on the page? Is that particular instance where? It's like bar num, so it's like it's wherever you did it. So in that case, I was doing it in a block, so it was right in the block. Okay. Yeah. I just saw it like, yeah, I just saw it like, yeah. What's your component? What do you mean by the same thing on the? Yeah. Yeah. Is this a microphone? Yeah. So, yeah, so which environment, which component was doing the environment variable stuff that was called dot env, like D-O-T-N-V. Yep. And you can already use environment variables, but that's what makes it simple. It's a load file into environment variables. Yeah. So some sort of best practices for where to store like symphony configuration, like in the Drupal environment. The thing I'm thinking of is like, right now there's some issues with the YAML parsing. Like if you have PCL library, it's more strict. So it'd be nice to be able to like say, no, I don't want to use that particular library for my project here. Oh, so tell me more, I'm actually not familiar with that. So there's a library that makes the YAML parsing more strict? Yeah, it looks like the symphony library decides if that PCL library is installed, use that, or use some default in parser that goes, is a less strict. So the question is like, if you... Is there a way to set that in your project environment? Is there like a preferred place to set like symphony configuration? Yeah, so the answer on that is gonna be case, it's gonna be very, very case by case. So it's like, hey, symphony is like doing this thing deep in the YAML parsing and I wanna maybe be able to control it, ends up being on a case by case basis. Usually if it's something that you can configure, it's gonna be configured via a parameter. So like twig.config parameter I showed earlier, where you turn debug from false to true, usually Drupal when they kind of integrate symphony, if they want something to be configurable, they'll expose it as a parameter. And then it may or may not be documented, but if you go to like the top of core.services.yml, you'll see a bunch of parameters there. Those are there for you to override. In that case, you can't override it. I think that symphony has decided that we want to use this extension of if it's available, because it's faster, else we'll fall back and be nice to you. So I don't think it's something that in the symphony world we've wanted you to configure. So it doesn't mean that it can't be, it's one of those things that it hasn't come up before, so somebody would have to propose and say I wanna make this configurable. That being said, not that you should run and do this, but with Drupal's container, everything is over-rideable. So in theory, you could, not that it would necessarily be worth it in this case, but in theory you could override the YAML file loader class and have it use your class instead, and then bypass that check by overriding some stuff. Yep, I love that you asked that question. Good. So I'm gonna repeat the part of your question here. So what's symphony's kind of, how does symphony break BC? What happens between two and three? And is our symphony three components compatible with Drupal? And could I, in my Drupal project, have some components, version 2.8, and other components, version 3.3? So first thing is that Drupal and symphony actually now have the same BC break and deprecation policy. It was actually started in symphony first, and Drupal has adopted it, which is amazing. And it works like this on minor versions, so like 2.5 to 2.6 to 2.7 to 2.8, symphony never breaks backwards compatibility. So it's actually cool because I believe when Drupal first came out, Drupal 8.0, they were on maybe 2.6 or 2.7, and then when, I don't know which one came out, Drupal 8.2 or something, they upgraded to symphony 2.8, and it wasn't a thing, because we don't break backwards compatibility, so it was no problem. Now what happens at 3.0? So this is the way it works, and I'm gonna explain it in a little bit of detail because Drupal's gonna work the same way, so it's a really kind of cool thing to understand. The difference between symphony 2.8 and symphony 3.0, actually let me say it different way, wow. When symphony, symphony 2.8 and symphony 3.0 came out on the same day, and symphony 3.0 contained no new features. What we do whenever the minor releases come out, 2.7, 2.8, is that we deprecate things, which means we don't like the way this function's called, so we're going to rename it. But we're gonna make the old function name call the new function name, so the old function name still works, that kind of thing. And when we do that though, we actually trigger a deprecation notice. It's actually a little bit of line of code that triggers a notice, and we actually silence it so you don't see the notice coming into your logs. But as you go through that old code path, or old code paths, in memory, there's actually being collected a bunch of notices saying these are deprecated code paths that you're using. So if you're on symphony 2.8 or Drupal 8.3, which uses symphony 2.8, there's actually a way for you, and I'm not sure exactly how they expose it yet in Drupal, there's a way for you on any page load to say, show me all of the deprecated features I'm using. And you'll see things like, hey, you're calling this function name, it should be this function name. So the name of the game is, for example, in a symphony app, if I'm on symphony 2.8 right now, and I want to upgrade to symphony 3, what I need to do is just make sure that I remove all the deprecated code paths from my project. Because the only difference between 2.8 and 3.0 is that we've removed the deprecated code paths, remove the old function name. So if you're on 2.8 and you've removed all the deprecated code, you just switch to 3.0 and everything's fine. So as far as Drupal is concerned, Drupal 8.4, I believe the plan is to go to symphony 3.0 something. And the way that's gonna work is when they change that, it will potentially break your application or break modules. But right now on 8.3, they have the opportunity to fix that. Because 8.3 has the new way, or sorry, 8.3 since it uses symphony 2.8, that's the last version in the symphony 2 series. That means that if a module or your code is using the old path that's gonna be removed, that module or your code just needs to use the new path that's sitting there waiting for you. So that means that Drupal 8.3 will be a time of people basically fixing and updating their code so that ideally by the time Drupal 8.4 comes out that's using symphony 3.2 or whatever, all of the old code paths will be fixed already. And so basically you won't even notice the change up to symphony 3.2 or whatever. Now as far as the individual components, the individual components can be installed on a version by version basis. So that is actually a cool thing. When I showed the debug one, I said you have to add tilde 2.8 or carrot 2.8 because if you just let it install the latest 3.2 it won't work. The reason it won't work is that Drupal's core says I need this library at version 2.8 maximum. So the Drupal core right now is restricting you in some ways. However, for example the symphony dot end components, the symphony dot end components, Drupal doesn't require that at all. So you can actually install the latest 3.2 version of the symphony dot end component today because it's available and there's nothing in your project that says it needs an old version of that. So the versions actually do work independently of each other. Like deprecated features. Does anybody know the answer to that? Like it is available. I just don't know how they're exposing it yet. So the answer is yes. Like in symphony we actually like basically have a little web debug toolbar at the bottom and you can click an icon and see the big list of everything that hit on the page. I don't know how Drupal's exposing it but the answer is yes, it's not through Composer. Drupal's going to expose this in some way so that when you refresh the page you can see the giant list of things. The only tricky thing is what you'll see is like, hey, don't call this method, call this method. And sometimes that might be your code that's calling the wrong method or sometimes that might be a contrib module you've installed and the contrib module is actually what needs to be updated. So it is a little bit tricky sometimes tracking down the correct things but you will see that big list and you'll know that hey, I still have five deprecations on this page so I cannot upgrade to Drupal 8.4 which uses symphony 3. Now Drupal's going to use the same thing in the future so Drupal itself will start deprecating things so that when you're on Drupal 8.4 for example you'll start seeing deprecation warnings thrown by Drupal itself. It says you need to correct this code before you go to Drupal 9. Yes, it will, yeah. So if P2 storm when you call a method name it'll have like a strike through it, it will have it, yeah, yeah, yeah. It's a less scientific way but at least when you start, you won't make new code and not notice it because you'll see the strike through it, yep. Yeah, I don't think it does but I'm not 100% sure. Yeah, yeah, so there is a web profiler module where you can get this nice web debug tool around the bottom and it collects lots of information. I just don't know if yet they have put the deprecation notices on there or not and they might in the future but they'll be an even more core official way to get the deprecation notices, I just don't know where they are. I'm gonna go. So you're actually on the mic. Just wanted to know if you could explain the symphony lock component one more time, like perhaps if you can give us a basic example of how we would use it. So I'll give you an example from one of my projects. We, when something happens, sometimes we, it sounds weird but we actually clone projects behind the scenes because we're basically reading code from different repositories and actually moving around branches and grabbing things. We use this on our tutorial site to grab different code from different tutorials and so one of the things we do is we clone a repository and then we actually move to a branch and then grab the contents of a file. Well if two requests come in at the same time and they both want something from the same repository, well we set it up just for file space that we don't clone that project twice, we only clone it once and then everybody kind of moves around on that same clone. So if two requests came at the same time, they would both try to like move branches at different times. The first request would like clone the project and then try to move to this branch. The next request would come in and right while that one was doing its work, it would move to a different branch and all of a sudden this would try to read that file from that branch and it wouldn't be there. So what we need to do is we need to basically say when this starts working with the repository that clone, it's going to actually, it's going to say, it's going to lock and say nobody can use the repository foobar. I'm going to create a lock called foobar and then over in this code, it's going to try to acquire the lock called foobar because it needs to read from that same repository and it will basically see that somebody else has already locked foobar and it will not be able to get that lock and in that case what you can do is you can actually fail and say nevermind I won't do my work or you can basically wait until that lock comes available. So behind the scenes what's basically doing is if you use for example the Redis driver for this, it's basically just setting a key in Redis that says there's a lock for foobar and so when this guy tries to acquire the lock he basically checks to see if that foobar key is inside of the Redis store and if it is, it's like okay, I'll wait. So it's for those, it's for race conditions. Other things would be like database connection stuff if you're doing some sort of heavy database operation and you don't want two processes to end up doing the same thing at the same time. Yeah, yeah. That's weird, it's like really edge casey but I've used like all of these things before. Yeah, back there. Did you say that the develop module comes? Yeah, it does and it's, yeah. So there's two, I didn't get any of that, so was that a yes? Yeah, yes, and there's two ways to install modules at this point or three or 10. You know, you can always still just use trust or just download a module but if you use Composer to install a module which is totally legal now, you can say Composer require drupal slash drush for example and install drush into your project. If you do that, then it will actually also bring the symphony var dumper components down with you. I think, yeah, you won't get it and so I'm guessing what they do, I don't know for sure. Guessing what they do is they basically have some conditional code. It's like well this feature doesn't work or isn't available if that component's not there. Yep, on the side you'd have to run a Composer to get that thing. So that's one of the advantages of using Composer to grab your modules. It's kind of cool like modules can now be like well I'm not a drupal module but I need these three other PHP libraries to really kick ass so if you use Composer to grab that module it gives them the opportunity to grab those things. So it's kind of like the, I was talking with somebody it's kind of like the module dependencies that you have. You know, this module depends on that other module but that system's all about just installing them. Hey, when I install devel, that has a dependency on this other module so we'll also install that but that system doesn't deal with actually getting the code itself. Composer's a really good solution for that. I don't think so. That's a great question. It would be up to the devel module but I don't think so. I'm guessing what would happen is I think it's used with like the kint functions or some other functions related to kint. I think that's where they use the var dumper. So I'm guessing you would either, well if you have intuitive ways, either you read the documentation, say that function looks cool and use it and it breaks or you read the documentation, say that function looks cool and when you use it they give you a clear exception that says if you want to use this function you need to install symphony var dumper. Hopefully that way. Hopefully not the first way where it's just like function not found. Good luck. All right, I'm gonna get off the stage. If you have any other questions, you can find me about anything. I was hoping symphony questions would be kind of about symphony in general so that was perfect.