Scott Keck-Warren
0:05
Hello developers, and welcome to the PHP Community Corner, where we have conversations with members of the web development community. I'm your host, Scott Keck Warren, and today we're talking with JD Lean about, uh, his article that he wrote for the June 2024 issue of PHP Architect and some of the projects that he's worked on, as well as his introduction to PHP. Okay. JD Lean is a senior full-stack web developer with rich experience in software architecture, database design, backend development, and frontend UI/UX design. He is passionate about crafting software that is maintainable with clean, understandable code. Meticulous about details, striving to polish user experiences and perform to the highest standard. He's also an alleged Tailwind CSS fanboy. Thank you, JD, for finding some time to talk to us today.
Yeah, thanks for having me on, Scott.
Scott Keck-Warren
0:52
Yeah, absolutely. So as we're a PHP podcast and you're a PHP developer, I always like to start out with the, how did you get into PHP and how did it kind of get its hooks into you?
Right. Well, I've been interested in code since I was about 12, and I used to dabble with QBasic on my IBM PC way back when. And, uh, as I got a little older, I started dabbling with doing more web stuff, and I became a kind of a web designer in about 1999 and At that time, PHP was starting to really pick up a lot of steam and it sort of seemed like the go-to way to make a web app. And so I started fairly early on in those days, but my first real serious job where I was focused on doing software development full-time was at Edmonton Public Library. And I got that job thinking I was gonna be doing a lot of PHP, like there were Drupal systems in place there and things like that. And incidentally, it ended up being heavy on Cold Fusion. So I did tons of ColdFusion programming, but it's not a very popular language and it doesn't have the kind of like ecosystem and, uh, kind of user base that PHP does. So over time I worked towards transitioning a lot of that ColdFusion code over to PHP. And I had friends who were really into Laravel and it just seemed like an excellent framework that came with everything you needed. It had so many features that got you started in a, in, gave you this really good structure to do a well-architected application. So I really liked it for that reason, and it's kind of what I know, and my background has long, long been PHP. And, uh, the few other things I've tried, I kind of tend to come back to PHP. So.
Scott Keck-Warren
2:33
That's fascinating. I, I really find it fascinating because I had the same kind of— like, I started out in QBasic. Like, that was my formative programming experience. And like, I got to— like, it was that gorilla game that you would like throw throw the bananas and you could like, the source code was there so you could fiddle with it. Um, and then you went to ColdFusion and then PHP, which is like a path that I've heard a lot of developers talk about before where they're like, I started with this and then I ended up in ColdFusion and now I'm in PHP. And I wonder if it's just like an age thing. And I don't mean to like, you know, age you or anything, but like that, I wonder if there's like a certain generation of programmers where a lot of them got into ColdFusion and then that was their tipping point into PHP.
Yeah, I'm kind of old, but I'm 42. But I think that's sort of incidental because I got into PHP more recently than it had been. It was quite popular kind of at the end of the '90s or the, or like maybe the early 2000s. But it just was a matter of the job I landed in. It was popular in that kind of environment. So you'll find a lot of like ColdFusion stacks in these like legacy codebases in municipal government and these types of things, which is where I was working. So I was working for Edmonton Public Library and they had been using ColdFusion since version 1.0. And in that time, I think there was long a desire to move away from it. And, and they had adopted Drupal for like their public website and things like that. And I was not a super big fan of Drupal. It just didn't really speak to me. But eventually I found Laravel and I just liked the flexibility you had with that because you could kind of build anything, but you had a little bit of a structure to sort of allow you to make sure things were done kind of the right way, or at least somebody hopefully smarter than me had thought of that in advance and figured it out, right? So there were all these kind of things in place that allowed you to build really quickly with it.
Scott Keck-Warren
4:26
Yeah, absolutely. So I imagine as someone who worked in municipal government doing web development, you had contact with other people. is the— is, is there a community of, of other, you know, municipal web developers? And how does that kind of, uh, how is, how is there a community for that? Or is there a community for that, I guess?
Uh, it's not really something I ran into because in my particular case, we worked on a small team. Like, there, there was kind of this library world of, uh, other, like, uh, coders in that space, but I never felt like there was a big sort of consolidation on one language or one tech stack, like the library aspect of things itself, which I didn't focus on too much because I was more doing infrastructure and support for the staff than the actual library systems themselves. But there are specialized systems and some of them are very archaic, like they don't even encrypt passwords and things like this. You're right. So there's, there's a bunch of systems out there and, and it's kind of a hodgepodge. I think, but the ColdFusion thing does seem to be something that comes up. Like here in Edmonton, we have Edmonton Public School Board. They're also big ColdFusion users. So it does seem to be a little bit of a theme that the ColdFusion thing is still active in like some government things or maybe some older, bigger companies where they have like old code that no one's gotten around to rewriting. That seems to be the bigger theme with that kind of stuff.
Scott Keck-Warren
5:58
Yeah. So that's definitely, definitely fascinating. I'm always curious about like the little like sub-communities that form within PHP. I wasn't sure if that was like one of them that created.
Scott Keck-Warren
6:10
Yeah. Yeah. Um, well, we'll be right back after this word from our sponsors. Do you want higher clarity in production, but don't have the time to earn your degree in observability? Me too. Forget logs, metrics, and traces. Honeybadger Insights is built around structured events. When you send your application logs and other events to Honeybadger, you'll unlock the power of Honeybadger's powerful new querying language, BadgerQL. You can then use BadgerQL to ask any question about your data, convert any event into a metric, and chart your metrics on a custom dashboard. You can do all of this on Honeybadger's free plan as part of their comprehensive monitoring suite, which includes error tracking, uptime monitoring, status pages, and more. Speaking of error tracking, did you know that an error is really just a first-class event in Honeybadger? In fact, you can use Insights and BadgerQL to explore all of your existing Honey Badger data in new ways. It's pretty cool. Give it a try today at honeybadger.io. That's honeybadger.io. And we're back with JD. So, uh, the reason we have you on today is that you wrote an article for PHP Architect. It's in the June 2024 issue. It's called Understanding PHP Attributes. So can you tell us a little bit about what PHP attributes are?
Yeah, for sure. Well, PHP attributes are a feature that has been introduced in PHP 8.0 originally, and they keep getting new built-in attributes kind of with every new version of PHP. And the idea is that you can add a little annotation of sorts, although the annotations specifically were kind of a feature of doc blocks like the Doctrine library used a lot of those where you'd have the@ symbol. So annotations are a little bit more of a formal way to do a lot of what those old annotations did, where you can add metadata to your code base. And the thing that led to me wanting to write this article is that when I first heard about attributes, I'm kind of thinking, what on earth would you do with this thing? It seems kind of like, like you're essentially decorating your code, but is, is there a way to actually use this for something? interesting and useful? And when I started digging into it, the answer is yes, there are some very cool things you can do with annotations. Like, for example, Spatie has a package that you can use with Laravel that allows you to add your routes right to your controllers. And you can have this kind of consolidate some of that code where you'd normally have to edit a routes file, and then you'd edit your controllers and And this allows you to kind of keep those in one place. So there's some pretty neat features like that. And the Symfony framework also uses these attributes extensively. There's many features that are enabled by that, that maybe historically you'd use inside of a doc block or something like that. So I find it to be kind of an interesting thing because it's, to me at least, it seemed very non-obvious, like what you would do with these attributes, but there's some pretty neat features that they enable.
Scott Keck-Warren
9:14
Yeah. And I, I really find them fascinating. I especially love the fact that like, not only has, so like PHP core introduced these and then they've started like, you know, in 8.1 and 8.2 and 8.3, we're getting new, uh, attributes that we can just throw on there that are supported by the language, which are way nice. Like, I don't remember if it's 8.4 or 8.3, but one of them says like, this is how you mark something as deprecated. Right. And now we're using that.
Yeah, that was, uh, 8.1, I believe in that case.
Scott Keck-Warren
9:40
Oh, okay. Yeah. And that's, and that's like something that like existed in docblocks before this, but it like didn't have full support. Right.
Yeah. Right. It's not part of the language. So the, the best you can hope for is that your IDE might flag it or something if you're using like, uh, PhpStorm. But, uh, but having it as part of the language makes it significantly more powerful.
Scott Keck-Warren
9:59
Yeah, absolutely. And then now we're seeing like the frameworks of like, obviously Symfony is one of them. The frameworks that are, you know, up to that version are saying, well, we're gonna embrace this and use this as part of our, as our part of our commonality. Um, so that's, it is really like a fascinating, like piece. Um, I know that like I read through your article and I was like, well, these attributes are neat. And then I was like, oh, now I see how I'm supposed to use these. Cause I just thought it was like a, it's a built-in feature for the core language essentially, not for, hey, I can actually add stuff to this to do things. It was a gap in my knowledge more or less. Yeah.
Yeah. And same with me as well. Like when I first started learning about this stuff, um, But that's, that's why I wanted to write the article, because there are some pretty neat things you can do with it. So I guess just to rehash a couple points from the article, you mentioned there's like a deprecated attribute, and then PHP 8.2 also introduced a sensitive parameter attribute, which is a neat one because that will actually allow you to apply that to a parameter, and then if it— it'll prevent it from showing up in logs. So if you have a password or a key or something like that, you can make sure that it doesn't leak all over your logs, which is a pretty cool— Use case. And then of course you can make your own custom attributes simply by— well, maybe not simply, but it's essentially like making a special class that is prefixed itself by another attribute, and that attribute itself can have other parameters and stuff. So you can have parameters for your attributes, and they're quite powerful in that way because you can have like other properties that you can change when you sort of tag another one of your classes with an attribute. And of course you can use an attribute on a class, or you can use an attribute on like a method within a class or a property in a class as well. So there's a lot of ways you can use them that don't immediately seem obvious when you start learning about this.
Scott Keck-Warren
11:53
Yeah, it's, it's really crazy powerful. I'm, I'm shocked at like what you can do with it. So, um, is there anything, anything else you want to mention about the article before we kind of move on to the next piece, or—
Uh, not really, uh, but, uh, yeah, if it's interesting to you, grab a copy of PHP Architect and, and read about it. I think it's a Hopefully it's a nice article. You think so?
Scott Keck-Warren
12:15
Absolutely. And like, thank you for, for writing the article. They're always looking for, for people to write. So it's nice to hear. It's nice to get, get these kind of nice, nice articles about new features in, in the language. Um, the other thing that we kind of wanted to talk about today was you have a, uh, a validator, uh, uh, project that you've written in Node. And, uh, can you talk a little bit about what it's like creating a package for an open source community that's not PHP?
Yeah, yeah. To be clear, it's not Node actually. It's a client-side package in this case, and it was written in TypeScript. But this was a need I had because I worked on a lot of forms, and I really like to do rich client-side validation. And Laravel is quite good at doing server-side validation. It has great features for that. But I like the performance of being able to do like, you know, instantaneous validation of certain things as you type. So if you have a Canadian postal code, for example, there's a very specific format it has to be. That was like a thing that came up all the time, or, you know, just simply validating something like an email address. So I made this package in— it was one of my first real forays into doing any kind of in-depth TypeScript code. And It's been, uh, it's been a really useful package. It hasn't been adopted super widely, but, uh, but, uh, like npm's like a massive ecosystem, right? So being able to get a package on there was kind of neat and more or less like it was a pretty smooth process. They like, you just kind of do everything from the command line to publish and everything like that.
Scott Keck-Warren
13:55
That's good to hear. I'm glad it's like, 'cause I know like in, in the Composer world, it's fairly easy to get something listed and updated and everything like that. So it's nice to hear that. You know, Node is the same situation, or npm is the same situation.
Node Package Manager. Yeah, yeah, tangentially related to Node, I guess, because it's sort of the back of all that, all those package managers and, you know, the code that you run to pull in a package and everything.
Scott Keck-Warren
14:23
So again, I'd like to thank you for your time today. Is there anything else you'd like to direct our listeners to before we let you go for today?
Yeah, well, there's one thing that I thought was kind of a fun little project that I did. It's on my GitHub, JD Lien, and it's called resume.md. And this is a fork of a project that someone else originally made, and they had this kind of silly resume from a TV show character or something on there. But I was working on this idea of, you know, a little while ago, I was looking for jobs and wanted to brush up my resume and going through this whole process of discovering like, what is the best way to write a tech resume and kind of what can you, what's, what are the good things and bad things to do? And one very good example that Gergely Orosz talked about in his book about writing tech resumes was this resume.md package. So it's like a little Python script where you can write a README file. And anyways, if anyone out there is interested in writing a resume, dig that up because I think it's a really great way to make a resume. And I've done some modifications to it to sort of smooth the workflow of working on that, where you can essentially within the README.md or not README.md, but the MD file, you can define a bunch of variables with your personal information and put all your experience and everything there. And then you've basically got a stylesheet you can edit to make it look however you want and stuff like that. So. anyone in the space of looking for employment and doing up a resume, that's a pretty cool way to do it, I think, because it results in a really nice clean PDF and you're just working on— you don't have to mess with Word and all the headaches of that. I never, never really liked doing fancy formatting in Word. So anyways, that's, that's the one thing I thought I'd point to. I thought was a fun project I worked on.
Scott Keck-Warren
16:10
I consume a lot of resumes from people that are looking for jobs, and I cannot tell you, like, you just want it to be as clean as possible. Like there, there are people that'll do real fancy resumes and they just like, you, sometimes they can't even read, um, like whatever it is they have in them. Yeah,
yeah, absolutely. That's, that's one of the things I discovered too, is that like, if you, if you're a normal guy like me looking for a job or something, uh, you're gonna look up templates or whatever. And I, for example, I went on Figma's thing and it's, Figma's a tool I use for just some design work sometimes, and they have some really awesome looking templates there. But then on the other side, if you're a hiring manager, you're going to look at those resumes and you're just going to struggle trying to find the information. And you got these fancy photos and all these, you know, all the styling stuff. But a lot of that kind of backfires because it just makes it harder for people to look through your resume. The average hiring manager, or at least the recruiter, will spend like 7 seconds looking at a resume. So you got to have the information really clear front and center. So anyways, that's, that's my pro tip to anyone writing a resume. Just keep it simple, keep it structured, put the important stuff first, right?
Scott Keck-Warren
17:21
Yep. And my pro tip is to do a spell check because I'm amazed at how often I get spelling errors in resumes.
So seems like it would go without saying, but
Scott Keck-Warren
17:28
yeah, that's like an automatic, like, oh, you misspelled programmer, that's out. That's a no-go. Yeah. So thank you again for finding time to talk to us today.
Yeah. Yeah. Thanks so much again, Scott, for having me on. You have a good one.
Scott Keck-Warren
17:40
Yeah, absolutely. You too. I had to say another heartfelt thank you to JD and to you for all of your time. And thank you for listening. If you're not already a subscriber, make sure you subscribe with whatever your preferred method is so you can get episodes when they're released. Make sure you turn on the automatic downloads as that does help other people find us. And maybe share this post with a coworker so they can learn as well. This podcast is available both as an audio version on the PHP Architect website, as well as a video version on our YouTube channel. This is Scott Keck Warren for the PHP Architect Community Corner, signing off and reminding you to keep listening, keep coding, and keep reading.