Laravel and Lumen 5.5, shareable models, and chat bots
September 12, 2017

"Laravel and Lumen 5.5, shareable models, and chat bots" Full Transcript

This is the full transcript of the Laravel News podcast episode #45 - “Laravel and Lumen 5.5, shareable models, and chat bots


Jacob Bennett: Welcome back everyone, to the [00:00:30] Laravel News Podcast. This is episode, pause until Michael tells me what it is. What episode is it, Michael? Forty five?

Michael Dyrynda: Forty five.

Jacob Bennett: Forty five?

Michael Dyrynda: Forty five.

Jacob Bennett: Okay. Well, since last time we recorded Laricon EU happened. Laravel 5.5 was released. Laravel certification was announced. There have been a ton of community links out there, and we've got a ton of ground to cover. So why don't we jump right into it? Laravel [00:01:00] 5.5. Michael, have you had a chance to look into all the different things that were released with Laravel 5.5?

Michael Dyrynda: Not all of it. There has been so much and I feel like because we've been covering the bits and pieces individually, as they've been announced over the last few months, you kind of lose sight of just how much has gone into this release. Maybe if you just look at it from the outset, that nothing has happened. You really [00:01:30] need to check out all of the work that's been done, the refactoring that's happened, the new features that have come in. Even Horizon on the side, that was released as a free piece of software to manage queues because it seems like it's something that a large part of the community is doing, and it hasn't really been a good way to do that. Overall, it's actually a pretty feature packed release.

Jacob Bennett: It's huge.

Michael Dyrynda: And Paul Redman actually released, in a blog post [00:02:00] on Laravel News, a video that goes along with all of the different features that have come out in this release. I encourage everyone to check it out, if you want like a ten minute overview of everything that's happened.

Jacob Bennett: Yeah. It's Laravel 5.5. It's in the show notes. It's on the website. It's really good. I watched it just the other day and it was very enlightening. I'm going to run down a couple of things that he talked about, the Whoops Package. In Laravel version 4, there was a Whoops Package, which in addition to showing you [00:02:30] the stack trace of what failed, it shows you exactly the lines that have failed on in your code, which has always been pretty cool. I really missed that. Collection dumping was something that was added in 5.5. So if you're in the middle of a collection pipeline, you can just call the dump method and it will do a var-dump out, either in your console or on the page. Then you can also have the ability to do DD instead of dump. That will dump and die. It will stop the execution of the pipeline [00:03:00] at that spot. You can do multiple dumps in one pipeline, which is pretty cool. They talked about how exceptions have a custom render method now, so you can render out on exception however you'd like. He talked about the responsible interface, which we're talked about a little bit on the show before.

Michael Dyrynda: We tried to.

Jacob Bennett: Yeah. Tried to. There is a new validate method that you can call directly on the requests that will not only validate what you are asking it for with the rules, but will also return the fields that you've [00:03:30] validated. So how many times have you had to do this validate, then you pass the request in, and then a list of rules, and then the next line after that is request only, and you're grabbing all the keys out that you've just validated. This basically shortcuts that and puts it all into one little thing. We talked about custom validation rules and objects and closures. Talked about new directives. Talked about front end presets. It's so hard to keep up. I told myself, I'm going to have to watch this video like three or four times. In addition [00:04:00] to that, there's other things that people have kind of forgotten about, like mailables can be directly rendered now. Do you remember that? You can have a mailable class.

Michael Dyrynda: Yeah, right in the browser.

Jacob Bennett: Right in the browser. You can just render it right on the browser, which makes it super easy to debug. There are special route, instead of saying route get or post route, you can say route view. And you can just pass in the pattern and then the view that you want to do. I had totally forgotten about that until, I think, two days ago. I was just like "Oh yeah. That's right. I think I have that available now." And sure enough, I did. There is just so much [00:04:30] stuff. It's kind of hard to remember.

Michael Dyrynda: Just as a public service announcement on that route view thing, there have been countless people who have submitted pour requests to the frame work, wanting to change the default routes file, to use route view instead of the route closure. Just for Taylor's sanity and for anyone else that's reading it, because a few people have gotten a bit antsy about it I think. Taylor is using that route closure for testing purposes for his own development needs. [00:05:00] For anyone thinking of submitting a pour request to change that closure to a route view ...

Jacob Bennett: Don't do it.

Michael Dyrynda: Just as a head's up, it's not going to get through.

Jacob Bennett: Don't do it. Don't waste your time. Thank you. Good head's up on that. There are two things that I kind of wanted to talk about that are in 5.5 that I don't know have gotten a ton of press. One of them is the width default that is available on relationships. Have you seen this Michael?

Michael Dyrynda: I haven't. Tell us about it.

Jacob Bennett: Okay. So what it is, is a lot of times you'll have [00:05:30] a relationship that will be defined on a let's say user and profile. You have user model and it has a profile method, which is a relationship, so it would say return this has one profile class or whatever. Well, what may happen is you may run into a situation at some point, where you do not have a profile that is linked up for that user. There is no relationship there. So if inside your view, you are [00:06:00] saying user, profile, avatar, it's going to throw you an error because there is no avatar, there is no profile, right? They don't have that profile relationship loaded. So what with default allows you to do, is on the end of that relationship, you can say return, this has one profile. And then you can say with default, and then you can pass an array of values that should be returned as a default, if they do not have a profile. You could say for example, avatar, and you could point it at some generic [00:06:30] image that you would use as an avatar if somebody did not have a profile that was linked up. So it's pretty cool. Instead of having to check in your view to say, using the null coalesce operator, saying is there a profile set, and if there isn't, go ahead and provide this default value for the avatar. You can just set it straight inside your model there, and it works pretty well. Just as a head's up. There is a little bit of a difference here. This does not mean that if a person has a profile relationship [00:07:00] but it does not have an avatar value set, that it will set this as the default. That's not what it means. What it means is that this array will be returned if the relationship is not defined. If the relationship is set as null when you call profile. Does that make sense?

Michael Dyrynda: Yeah.

Jacob Bennett: That's an important distinction to make there. So that's the width default helper, which is pretty awesome. I think there is a post out there Code by Jeff, who is a prolific blogger, [00:07:30] has a medium post out there about this. About the width default. In addition to that, there is also a new helper, which is called the Optional Helper. Have you looked at this much?

Michael Dyrynda: This one I did and I wasn't sure why one would use it over using the null coalesce operator, but you were saying that the null coalesce operator only works if you go one level deep. The optional one would handle the nested relationships?

Jacob Bennett: I believe that's right. [00:08:00] Let's say for example exactly what we were talking about a minute ago. User, arrow, profile, arrow, avatar. So like if you were using the null coalesce operator, you could say "Hey, is user profile set??" That would work, if you said user profile??, that would say if it's not set, use this value instead. You could not say user profile avatar??, because if the profile isn't set, it's going to throw [00:08:30] you an error anyway, right? It's only going to check for null. It's not going to say "If profile is null and if the avatar is null," It's going to throw an error because it's trying to get the value of a null, when ever it returns profile.

Michael Dyrynda: Yeah.

Jacob Bennett: So it only works one level deep. So what you can do with the Optional Helper is you can wrap that user profile in the Optional Helper, so you say optional, user profile, and at the end of that you put avatar. What that will do is that will return null for you, if [00:09:00] in fact there is no profile set. So pretty much what it will do is it will return the value that supposed to be there or it will return something that you can string another thing on to. Jeffery Waugh has a really good video on it on Laracasts, which we will also link up in the show notes, but it's worth checking out. These are two things that will kind of help mitigate some of these problems that you might have in your view, where you are assuming that you have something available and you're running into issues where you're getting these ... [00:09:30] I'm trying to even remember what the error is that you get.

Michael Dyrynda: Trying to access property on null, something like that.

Jacob Bennett: Yeah. Something like that. These are two things that are in 5.5 that help to mitigate this problem that you may have. So we'll link that up in the show notes. Like I said, there's a really good post out there. Thanks Jeff Madison for making that and for everybody else who submitted the pour requests to make that happen in Laravel 5.5.

Michael Dyrynda: Yeah. And to everyone who contributed to Laravel 5.5.

Jacob Bennett: Absolutely. It's awesome really. I [00:10:00] got it already installed in two of my applications and love playing around with it, so it's pretty cool. I think we could probably spend a long time on this but we'll move on, on Laravel 5.5. In addition, Lumin 5.5 was released. This is just to kind of go along with the Laravel 5.5 release schedule, I believe.

Michael Dyrynda: Yeah. It's mainly just a maintenance release, so all of the underlying packages have been updated to use the framework 5.5 components. If you are using Lumin, [00:10:30] feel free to upgrade. It should be a moderate upgrade path. The upgrade guide is just a matter of following along with what you've done for Laravel itself. Follow the Laravel upgrade and you'll be able to upgrade your Lumin install nice and quickly.

Jacob Bennett: There we go. Hey, let's go ahead and jump into some controversy. Laravel certification. We are going to maintain a very neutral, middle of the road stance on this. [00:11:00] We are going to inform you about what it is and we are going to try and stay right in the middle here. There is some really, really good stuff about this, and then there are some concerns that have also been raised by people in the community. We are definitely fans of the people who have put this together and know there's been a lot of hard work that has gone on behind the scenes to make this a reality. At the same time, we don't want to dismiss the concerns of the people who have them. Let's talk about what it is and we are going to withhold opinions for whatever they're worth on other channels [00:11:30] that we would talk about them on. Sound good Michael?

Michael Dyrynda: Sure. Sounds good to me.

Jacob Bennett: Okay. So why don't you talk to me about what the Laravel certification program is?

Michael Dyrynda: Cool. So the Laravel certification program was announced, originally at Laracon EU in 2016. It was go here, it's coming soon, we'll provide you with more information. So Sean McCall, whose been working tirelessly for the last couple of years, has got a page up now, which has got our [00:12:00] long awaited pricing available. It looks like it's going to be predominately targeted towards, I guess, the EU market, because all the pricing is in EU. I know he's based over in Amsterdam, I believe. It makes sense that's where the business is running, licensing the Laravel name from Taylor. Essentially, you need to be fluent in building apps use the Laravel framework in version 5.5. So if you're doing this on a day to day basis in your regular job, then this [00:12:30] course is probably aimed at you. It's going to help you to basically verify the knowledge that you already have of the framework and of what you're doing day to day. If you've never built an application before, you might want to read through the Laravel documentation. This is something that Taylor says all the time. It's something that a lot of the community members say a lot of the time. If you open up documentation and start at the very top and work your way through to the very bottom, it really does read like a book. From chapter to [00:13:00] chapter, or from topic to topic, you will learn progressively all the things you need to know as you would be building a Laravel application. So if you've read the documentation, you will have a good understand of what is needed in order to past this certification. The topics that are covered as part of the examination are HDPT, it covers routing and blank templating, services, security and collections, and all that kind of stuff and definitely eloquent. The knowledge that's being tested is what we would consider to be the widely accepted [00:13:30] best practices within the community. You'll also need to have a working knowledge of modern PHV versions. So you'll have to understand as well as that object oriented program, closures and other commonly used features. There is a FNAQ section on the Laravel website for the certification. This is not being done in isolation. There's a board of advisors that have been put together with this as well. Sean's been working with Taylor as obviously the creator [00:14:00] of the framework. He's been working with some prominent community members in Frake and also Chris Keithland from Vehicle. It's got community backing as well.

Jacob Bennett: Yup. For sure. The pricing is 249 Euros, which is almost $300 US. There is also a team certification, which is 1245 Euros, which is about $1500 US. Right now there is a pre-order discount of about 50 Euros on the personal certification and 15 percent [00:14:30] on the team certification. So if you want any information about that, you can find out more about at Laravel.com/certification. We've got a few other things here. Botman 2.0, PHP Chatbot framework was released. Pretty cool. Chervil's models package. I looked at this before we started the show. It looks really cool and we could talk about that. Laravel Podcasts season three. So, hmm, Laravel Podcast season three, let's start with that.

Michael Dyrynda: Okay.

Jacob Bennett: Laravel [00:15:00] Podcasts was hosted initially by Sean McCool and was with Taylor and Jeffery and a couple of other people that they would have on a random sort of schedule. Then it was taken over by Matt Stoffer and Jeffery and Taylor would be on there. There was a little bit of a lull in their release cycle. I think everybody just got busy, right? Babies and all that stuff. Matt and Jeffery both had new babies and Taylor, of course, is always hard at work, so Matt is kind of, I think, taking [00:15:30] this in a little bit of a different direction for what they're calling Laravel Podcast season three. So season one would have been when Sean McCool was in charge of it. Season two would have been when Matt first took over. Now season three is kind of a little bit of a departure from what it was, to something that Matt is kind of teasing. Did he put the teaser out there?

Michael Dyrynda: The teaser was out yesterday, yeah.

Jacob Bennett: Okay. So we're not spoiling anything. It sounds like it's going to be like an interview sort of format, which is different than what it's been before. I think [00:16:00] his goal is really to kind of get to some of the community members who you don't hear from. They do a lot of work behind the scenes, but you don't know their story. You don't know who they are. I think he's looking to interview some of those people and give them a little bit of shine. Use the Laravel Podcast to give them some credit where credit's due.

Michael Dyrynda: Hey, definitely reaching out to the community and making sure that it's not the same voices over and over. We have that level of direction from the likes of Adam and Jeff and [00:16:30] Taylor and Matt himself. Everyone knows about Eric Barnes. There are people like that in the community that you hear from all the time, but there are obviously thousands upon thousands of people using the Laravel framework out there in the wild. It's a good opportunity for anyone and everyone to have their voice heard. I think it's a good direction. I've seen some of the names that Matt is hoping to interview. There are some names I've submitted [00:17:00] myself to him. These people that you see around the edges. People like Till who is always pushing out the change logs for the new Laravel releases that just quietly goes about doing that, but who he is and what he does other than that, we don't know. It would be certainly interesting to hear those stories. I'm looking forward to the direction that the podcast goes in, going forward.

Jacob Bennett: Yeah. For sure. Me too. It sounds like it's going to be really awesome. [00:17:30] And he's got some new theme music, right?

Michael Dyrynda: Yeah. Love the music. He was saying that he paid a favorite producer of his to put that music together. It was like the Laravel podcast, not that it ever wasn't, but it feels like it's all grown up now.

Jacob Bennett: Yeah. He sent something to us in telegram and said "Hey, what do you think of this music?" I said, "It sounds amazing. A little too amazing. We're not looking for any competition" is what I told him. It does. It sounds really good. A little bit jealous. We need to change [00:18:00] our music up. We're going to have to hire somebody really good to make our music for the Laravel News Podcast. We'll have to get Eric on board with that. Maybe Eric could make us some music. That would be horrendous.

Michael Dyrynda: I'd love to hear Eric sing a song for us.

Jacob Bennett: There we go. Okay.

Michael Dyrynda: He could do like a Hip Hop intro.

Jacob Bennett: Yeah. I wanted to talk about the Chervil's models package.

Michael Dyrynda: We can't move on yet. Hang on. Hang on. We need to check out Laravel Podcasts.com. Make sure that you subscribe to that show in your pod catcher of choice, if you have not already. [00:18:30] If there is anyone in the community that you would like to hear from, anyone that you would like to hear interviewed, you can send your suggestions to @Laravelpodcasts on Tweeter. It would be good to engage people. I think he's aiming to do one a month. There not going to be off the cuff. It's not going to be friends talking. Not that we're not all friends in the community, but it's not someone that you know. There's a lot of work that goes into these kinds of interviews because he's going to try and do the back story. [00:19:00] He's going to try and get a bit of history from these people. I hope I'm not talking him up too much about the work that's involved, but I'm really looking forward to it. As I've said, if you've got any suggestions. He's got 60 he said, in a trailer list that he's ready to interview already so I don't know when he's going to interview all of these people, but I certainly think that weight of numbers might guide the order that we go through that list in. [00:19:30] Don't be shy and I hope that it is a big success in the new season.

Jacob Bennett: It will be. It always is. Matt does such a great job with that stuff. Looking forward to it. Okay. To other things. Chervil's model package and I wanted to talk a little bit about this Botman Chatbot framework as well, if we have some time. So we'll go quick here. The Chervil's model package, this is put out by Kye Sesnowski, and the use case for it is basically as follows. You can [00:20:00] take and create a sharable link with a possibility of having an expiration and a possibility of needing a password. What it allows you to do is, it allows you to create a sharable link, which gives you access to a particular resource. So for instance, if there was a user that you wanted someone to be able to edit, you didn't want them to be able to edit all users, but they're not an admin, so you want to give them access to edit a single user, [00:20:30] you can now create a sharable link, which you can give to them, which will allow them to access that one particular resource and modify it. So this is pretty cool. It reminds me a lot of like a Get Sharable link feature, like you'd have on Dropbox or Google drive or something like that, where you can just grab a sharable link and send it to somebody. They could view it or whatever. I'm sure you can probably limit as well. Like am I just giving them the ability to see this? Like am I giving the ability to show it or to edit it, or whatever [00:21:00] it is? I'm not exactly sure to be honest, how it works behind the scenes. If it by passes the authorization check on like a route group or something like that, or gives you a temporary authorization that would work. I need to look into it a little bit more, but just reading through it, I was like "Oh, this seems super useful. I'm sure there are a lot of people who could use this, or who have had a need for this before," or even just hearing the idea, are like "Oh yeah, I could use that somewhere."

Michael Dyrynda: Yeah.

Jacob Bennett: So I thought I'd just mention it here. You can check it out on Laravel-news.com. We'll make sure we link it up in the show [00:21:30] notes and check it out. Okay. Check it out. In addition to that, I don't know if we'll talked a little bit about this, we did, we talked about this somewhere. I think it was on Laravel News Podcast. That create temporary URL kind of thing, for anything that you're using in S3, Yeah. That's pretty cool too. It kind of goes along with this a little bit. Botman 2.0. Let's talk about this real quickly and I think we're going to wrap things up.

Michael Dyrynda: Let's do it. I have not used Botman at all. I have seen Marcel Pursio speak about it [00:22:00] often. He's always Tweeting about it. He's really enthused by it. There's heaps of people using it and I hadn't really seen a use case for it until very recently, where someone had mentioned that you could configure like a Facebook page to have a bot running on it. I thought that would actually be kind of useful for me in my new role. Not that it's something that anyone has asked for specifically, but it's something that I could do as one of those [00:22:30] end of day, end of week kind of I've got a bit of time, I might just play around with this over a few weeks and put together a chatbot that could be used for basic levels of support, like my internet is down or something like that. Obviously, there's a demand for it. There's a lot of people using this package. If the activity on Gethub is anything to go by, it's quite popular.

Jacob Bennett: Yeah. It was Tweeted out the other day. I'm trying to find it. Here it is. Christophe [00:23:00] Rumple, he published an article about using Laravel and Botman, on how to set it up like a telegram bot. I asked, said basically "What are some of the things that you guys are using these for?" Marcel basically said "Think of it as another interface to use your application", which I thought was a good way to phrase it. We talked about this last time with incoming email and how you can handle incoming email with Laravel. It's the same sort of idea with chatbot. He basically tweeted back "Filling out forms using a conversation", [00:23:30] which I thought was pretty interesting. So you can ask them for information incrementally. Hey what's your name? Hey what's your address? Hey, blah, blah, blah. Whatever. You can do it that way. In addition, he was talking about like you said, like this bots to almost handle user questions, things like that. One thing that he posted that I thought was really cool, that he has built is a slackbot that uses the Forge API to provision new sites and servers from [00:24:00] slack. So you can say like Forgebot help, they'll give you all the commands you can use, @forge bot, new sites, give it the name of a site and it will go ahead and put a new site onto a specified server, straight from Slack, which is pretty cool.

Michael Dyrynda: Yeah.

Jacob Bennett: When I started thinking about it that way, I could think of some places where I could use this. Another thing he said was think about your user sends you an image, you process it and reply something back. There's just a number of cool things that you could do when you think about it as another interface for [00:24:30] your application. I know Jason McQuirey had said that he had some SMS thing, where he could send through an SMS and his application would run like a shift or something, right? Yeah. All sorts of this stuff. It makes it really easy to do it. I'll be interested in checking into this and I'll let you know what I come up with as far as how I'm using it.

Michael Dyrynda: Yeah. I think I might check it out as well and have a play around with it, because I've just redone our sign up form for new customers. [00:25:00] When you say you could use it as a sign up thing, maybe I could have a play around with that as an interactive sign up. I like it.

Jacob Bennett: Yeah. Pretty neat. Well, I think that about wraps it up. You got anything else we want to talk about today?

Michael Dyrynda: No. I don't think so.

Jacob Bennett: Excellent. We are on episode, what is it? Forty five?

Michael Dyrynda: Forty five.

Jacob Bennett: Episode forty five. Thank you so much everyone for listening. I'm going to make this really fast. Here we go. Ready? Thanks so much for listening. You can find show notes for this episode at Laravel-news.com/podcast/45. Thank you Eric for making that so we don't have to deal with simple cached issues right now [00:25:30] with not having perma links. If you like the show, please write us up five stars in iTunes or your pod catcher of choice. If you have questions, hit us up at our personal Twitter accounts or at Laravelnews on Twitter. We appreciate all of the community members that put time and effort in getting 5.5 out the door. Thank you so much to Taylor, our leader, our commander in chief, for all that you do for your wonderful groupies and fanboys and fangirls out here. We love you.

Michael Dyrynda: Yeah. Taylor, never stop. We love [00:26:00] everything you do for our community. A lot of us wouldn't be where we are if it wasn't for the framework.

Jacob Bennett: Absolutely. Whole heartedly agree. Alright Michael. That's it. That's as fast as I could do it.

Michael Dyrynda: That was beautiful Jake.

Jacob Bennett: Thanks man.

Michael Dyrynda: I appreciate it.

Jacob Bennett: Alright. Thanks everyone. We'll see you in two weeks.

Michael Dyrynda: Until next time. See yeah.

Jacob Bennett: Laravel News out.

Laravel News Partners

Newsletter

Join the weekly newsletter and never miss out on new tips, tutorials, and more.