Scott Keck-Warren
0:06
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-Warrent, and today we're talking with Cesar Mendez about how he got started in PHP, how he breeds dragon fruits, and his article on full text search in Laravel applications in the newest issue of PHP Architect. Cesar Mendez is a systems engineer with more than 8 years of working with many PHP tools, such as Laravel, Falcon, Yee, WordPress, and WordPress. Fan of optimizing things, adventurer, and curious. When not programming, you can find him doing road trips, hiking, cooking, and creating new dragon fruit breeds. Thanks, Cesar, for finding some time to talk to us today.
Thank you. A pleasure to be here, Scott.
Scott Keck-Warren
0:50
Yeah, great. Um, so I usually like to start out these conversations and talk about how is it that you got into the PHP ecosystem?
It was a long time ago. I was in high school, like 2 years before finishing high school, and I was like playing video games. And one of the— of those video games, like, I could build like custom websites for like for communities of that video game. And that's when I started searching how to build websites. to build my own community. And that's when I find out about PHP. So basically I started with blogs and forums, and since then I started doing freelancing and stuff like that with PHP.
Scott Keck-Warren
1:39
Yeah, that's awesome. I think it, like, I'm always amazed at how, how often people are like, well, I have this like little thing that I want to do. And then they go, PHP is the way to solve that problem. Like, no, no question whatsoever. So, um, I also noticed that like while I was doing research for, for this interview, that you have like a very active, um, like GitHub profile. Can you, can you talk to us a little bit about how you got into so, like so many, it seems like there's a lot of open source contributions for somebody who does just a few every so often. So can you talk to us a little bit about your open source contributions?
Yeah, I always want— I always wanted to contribute to open source, but like I didn't find a way to do it. So after attending Tech on 2023, and speaking with Nuno Maduro, like, he encouraged me, like, to begin with little things. Like, you don't have to build a whole library or find the, like, the hardest bug on any project to solve. Like, if you find anything, even a typo, you can do it. So right after that conversation, I think like 3 or 4 weeks after that, I made my first open source contribution. That actually was a typo on the Livewire documentation. And after that, just by using the libraries, I find things that I needed to have on my project. So they didn't exist. So I found the opportunity there to add things so everyone could benefit from that.
Scott Keck-Warren
3:12
Yeah, that's awesome. I think it's, it's always amazing to me how, how much easier it is to get into helping with the documentation than it is with like the source code. Cause, cause like you can like do that where you like, I, that was one of my first open source contributions where I was like, well, they misspelled this word. So I went in there and I fixed the word and then like it sat there for a while and then somebody merged it and I was like, hey, I'm an open source contributor. Um, but it's, but it is really like, it is so easy to just go, okay, well, all these projects need some help with their documentation, you know? And it's, it's not, it could be like they need help writing it or they need help translating it or they need help, like. working through it, but that's always just like a great, a great way to get into that. So is that, is that kind of where you've been recently is just documentation and, and little things, or have you kind of reached out further than that?
No, like so far I have also looked into the issues tab of some Laravel projects. And if I find something that I can do, then I jump in and create a pull request. Right now I'm like, I want to contribute more. So what I'm doing is I go into the issues tab, and if I find something that I can work on, then I go ahead and create a pull request for that. And then the process goes on that the team reviews it and they do any suggestions, and I work on that. So, so far it has worked this way, and I'm committing to do it like for this year. Uh, do, do this to go to the issues and fix bugs.
Scott Keck-Warren
4:43
Awesome. That sounds like a really, really noble, noble pursuit for, for sure. Um, so I realized I glossed over in your, in your bio that you create new dragon fruit breeds. Can you, can you tell us a little bit about that? 'Cause I think that's also interesting. Like how does it— so, so dragon fruit's like a fruit and it has like, it's the one that's the, like the white with the black dots on the inside, right? Is that dragon fruit?
Scott Keck-Warren
5:05
And it looks kind of crazy looking. Yeah. So like, how is it that you, you create new, new, uh, breeds of dragon fruit?
Yeah, so during the pandemic, I knew about this fruit that is called the dragon fruit. In Spanish, it's pitahaya. So I was amazed by it. And when I discovered that this was a cactus, actually, not, not like a, a plant that we will say like a an apple, a pear, orange, but more like a, a cactus. Then I learned that you can make as many varieties as you like. Like, for example, I want to make one that is the flower is yellow and also the fruit is yellow, because right now we have fruits that are flowers that are red. And because the most common one is the white flower But some guy called Edgar Valdivia, he created a new breed that the flowers are like a purple, red, and this shade of colors. So that motivated me to create also a new breed of dragon fruits. Like, yeah, because you also have the one that is red on the inside with the black dots. So working on that. Yeah, so it's basically you select the pollen of one kind of dragonfruit and put it on the flower of another breed of dragonfruit, and by combination, trial and error, you create a new breed. Yeah, it will be a long process, but I'm willing to take it.
Scott Keck-Warren
6:42
Yeah, that really is fascinating. It's kind of like programming with biology, right?
Yeah, yeah, yeah. And you learn a lot of things because you, you can tune the sweetness, the size, the characteristic of the plant. So, yeah, it's really fun.
Scott Keck-Warren
6:57
I will definitely have to look into that more. That's kind of curious. Very interesting. So, 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 Honeybadger 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 Cesar Mendez. Um, so one of the real reasons that we had you on, on the podcast today is that you have an article in the July 2024 issue of PHP Architect called Advanced Search for Laravel Applications. Can you talk to us a little bit about what the article discusses?
Yeah, so this article talks about the something called full-text search that you can use this when you are dealing with a huge amount of documents and you really want like almost instant results. This is something very used in things like search engines like Bing, Google, on sites like eBay, Amazon, or any big online store.
Scott Keck-Warren
8:43
So occasionally, like when I read the articles in the, in the magazine, I'm like, oh, this is something that like I've heard of, but I don't really know what it is. And like, I read through the article and I was like, oh, I can see how this is like very applicable to like a lot of different things. Right. Cause it's always like, I'm searching on things across different record types. And like, uh, the example that I came up with is like, we have a solution where we have various types. We have like vendors and we have checks and we have purchase orders. And so being able to search across all of those using just like a common interface would be really beneficial to our users. So, that's like— that was how I kind of saw it. Is that a correct use case?
Yeah. For that, like, you will need multiple indexes. Meili Search does support multi-search, that you can search multiple indexes and also run multiple queries to multiple documents. But I think where it shines is that you search add one collection at a time. For example, you have your invoices index, you have your articles indexes and things like that.
Scott Keck-Warren
9:51
But, but it's fast enough that you could like query like 4 of them and get the results back in real time and not have to like sit there and wait for it to generate?
Yeah, for example, there is something called bool search or Boolean search. That is when you are nesting nest— they are nesting too many OR or AND conditionals in a search query. So when you start adding more AND and OR conditions to the query, usually on SQL databases it turns really, really slow. So when using a text search, it just retrieves in no time, really fast. And that's because of the use of the inverted index. Like this approach allows you to search things faster than with a binary tree. That is the, or a B-tree that is used on, on relational databases. Yeah.
Scott Keck-Warren
10:49
And I think like, so that, that inverted tree, I don't think we've discussed that yet. It's like, the idea is you like let or parse all your, all your text and then like split it into pieces. Then you go, okay, well, any document that says PHP, is here. And anyone that says Caesar is here. So now we can find all the articles really fast that say Caesar PHP, right?
Yeah, exactly. And also like the search time for the inverted index tree on average is, if we talk about our notation, is 1. But if we use the conventional B-tree, is a logarithm of the size of the dataset. So retrieving each token is on average just one request instead of having to serve the, the tree.
Scott Keck-Warren
11:39
That's really fascinating. I gotta, I gotta look into this more. I didn't even know that piece. That's, that's another helpful piece. Um, the, the one thing I do wanna point out is like, it is a Laravel-specific article, like at the tail end, but realistically, like anybody can use this, right? Like it doesn't, it isn't even PHP-specific. You can. I can't remember the backend solution, but there's what— you don't have to be using PHP specifically for this.
Yeah. So, you don't need to use PHP. MeliSearch also have an API that you can directly use in curl or any library or client that supports doing POST requests or GET requests, HTTP requests. At all. You can run any query to Meili Search or any operation. Also with Laravel, we have Laravel Scout that have native support for Meili Search, like it's out of the box supported. So it integrates very well with all the ecosystem, like things like Eloquent that you just insert data, like save the model, and it synchronizes and insert the information in Meili Search.
Scott Keck-Warren
12:53
Is there anything else you'd like to direct our listeners to before we let you go for today?
Yeah, I encourage anyone to join any of your community, like developer communities. We have a great community at PHP Tech, like the conference. But if you have anyone, a local user group, or any conference that you want to attend, I really encourage you to do that because you will meet really nice people. We'll see, uh, how to do things differently, and maybe you can apply that in your projects or actual work.
Scott Keck-Warren
13:29
Awesome. Thank you again for, for coming today. Yeah,
and thank you for the invitation.
Scott Keck-Warren
13:35
Yeah, no problem.
Scott Keck-Warren
13:36
Yeah, it was great. I have to say another heartfelt thank you to Cesar for all of his time today, and thank you for listening to our podcast. If you're not already a subscriber, make sure you subscribe with whatever your preferred method is so you can get the episodes as soon as they're released. Maybe share this post with a coworker so they can learn from it as well. This podcast is available both in 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.