Scott Keck-Warren
0:05
Hello developers, and welcome to the PHP Architect Community Corner, where we have conversations with members of the web development community. I'm your host, Scott Keck-Moren, and today we're talking with Savio Resende about his Jacked PHP book that just was published in the PHP Architect publications. Savio Resende has worked in software engineering for more than 19 years. He's worked for many companies in the public and private sectors, having had the opportunity to work for Brazil's federal government. Between the private sector's projects, he's worked in projects that serve MIT, London's Metropolitan Archives, Costco's Hearing Aid Center, and more. Thank you for finding some time to talk to us today.
Scott Keck-Warren
0:41
Yeah, absolutely. So, yeah, absolutely. So you kind of came onto my radar because you wrote a book for the PHP Architect publications. I don't know what they call that exactly now that I think about it, about OpenSWAL. And can you talk to us a little bit about what it is that OpenSWAL is?
Yeah, OpenSwoll is a PHP extension aiming to provide a better framework for asynchronous programming in the PHP ecosystem. Not that it was not possible before, but it's a different approach and it makes it simpler. It has better performance as an outcome. And I got very curious since the beginning. And I decided to write the book after experimenting with the tool because I thought that people were missing that out. So that's basically it. So PHP OpenSwoll provides a framework for asynchronous programming. And because of that, event-oriented architectures become simpler. And by that, I mean, when you have to have an event loop, for example, to create a server, with PHP only, without a web server. Yeah, they have that out of the box. And if you want to implement your own, it's actually pretty simple as well, between other functionalities that we can discuss further if you want.
Scott Keck-Warren
2:08
Okay. Yeah. And I think, so ultimately, can we talk a little bit about how the asynchronous piece of it? Because that's kind of a different paradigm than what most PHP developers are. So can we talk a little bit about what asynchronous programming is and how that works?
Yep. One thing that, because normally web development doesn't go on the asynchronous part other than in the JavaScript side of things. So because JavaScript by nature is something that more often you end up into the situation where you have a race condition due to callbacks not getting back on time. And that's basically how it feels like When we talk about asynchronous programming, you can— how can I word it— dispatch events while— dispatch functionalities, functions, or call specific functionalities while you're waiting for a previous call. And you can synchronize those 2 calls at a certain point. in your code. In other words, you can do more than one thing at the same time. Not necessarily with every asynchronous option, because there is the coroutine approach and the multiple subprocesses approach. Depending on what you need to accomplish, you would go for a coroutine, or you would go to a subprocess. It really depends on the use case. Examples of that, for example, is if you have to make multiple calls to different APIs and they don't depend on each other, you don't have to wait for the previous call to do the next call. You can dispatch them in parallel and put the end of both to wait for each other so you can synchronize the data in your code. at the end of both. And then you can continue. So, that's the type of experience in the development side of things look like.
Scott Keck-Warren
4:22
Okay. Yeah. And I think like that's like the best example that I always have of these is like I have to make multiple API requests. And I can just like say, okay, well, I need to do 10 API requests. It doesn't matter what order they return in. I'm just gonna fire them all off and let them do their thing. And then when they're all done, then at the end, I'll smoosh all the results together. Like that's, that's really like, to me, I'm like, every time somebody says like, this is like really powerful and it makes it so much faster, I'm just like, I just don't get it. Like I get like the logical, like 1, 2, 3, 4, 5, but I don't understand it when it's like, well, we took those 1, 2, 3, 4, 5 and we did it all at the same time. So it's always like really kind of confusing to me to try and process these things.
So, uh, one, one thing about that that I would like to add is the, the fact that, for example, I don't know if you worked with asynchronous programming before OpenSwoll, but it's pretty hard in PHP world because you have data. race condition when you want to access a specific piece of memory. And this is one of the things that OpenSWOOL makes easier, is how you share data between those coroutines or those processes. It becomes more predictable, and the framework offers tools for you to do that. So, yeah.
Scott Keck-Warren
5:33
And maybe this is my lack of understanding, but so, because there's like a there's a PHP user space piece of this, right? Where you have the functions that you're writing that are interacting with the Svelte framework. And is there also extensions or does PHP just kind of natively out of the box support this?
No, no, no. Yeah. You have to install the extension. So the extensions are the extensible— that's where the PHP shines, right? Because it's an extensible programming language through those extensions. And then you can enhance PHP functionality through those. And they actually hook into native PHP functionalities when needed to enhance the native functionalities, or they implement their own. One example of that, just to put a context into it, is when you have a MySQL connection, for example. If you have a MySQL connection, you would use like— MySQLi. PDO extension that you normally have installed with your PHP installation. And you will do that. But then those connections might fail if you are interacting with the PHP OpenSOL functionalities because of the asynchronous style and the concurrent connections, stuff like that. So to port those into an open SSO without conflicts. They hook into those connections or those drivers. And forgive if I'm expressing myself in a weird manner. I'm not very familiar in explaining this part of the process. But they hook into those connectors and make them support the the asynchronous process that OpenSOL implements, making them possible. Another thing to put in context, for example, is cURLs. For example, if you want to enable cURL connections to be supported by the asynchronous processing, when you're installing OpenSOL, you have to enable that. So you use native cURL functions. in PHP in the context of OpenSOL, and you don't have conflicts. Forgive me. And that's basically how it works. So OpenSOL can hook into other native or other extensions functionalities to make them support the context where it runs. And yeah, like, and just to bring to the conversation. I don't know if this is very important here, but one thing that I found interesting is that recently the PHP community adopted FrankenPHP. And that allows— FrankenPHP allows PHP extensions to be built, actually make it easier for PHP extensions to be built in Golang, which is pretty interesting. So I'm eager to see what is coming out there.
Scott Keck-Warren
8:48
Yeah. And that was like one of the examples that you have, like in your book, it's like building an HTTP server and like processing like the events through HTTP like that. And again, like, cause, cause like I was trying to figure out like how this fits in, like in a world where we have like FrankenPHP, which is like really kind of like set up to do something similar, but not, but different. Right. It's like similar, but different. Um, like, like where do you see like OpenSwoll kind of fitting within like the ecosystem? Like I, cause I can, I can look at it and say like, well, this makes sense for me to do. you know, multiprocessing of like API requests. But I can also see like, well, maybe I can make like a really, really fast like thing that just like accepts webhooks as fast as possible. So where do you kind of see like that fitting?
Yeah. I started to play with openSwole before all of that come to light. Like Phreak and PHP and other projects out there. The way— not necessarily openSwole. I started to play with the project when it was just Suo. OpenSuo, just to put in context, is a fork of the other project and now is maintained basically by a community that dedicates to the documentation more in English. The Suo documentation is originally written in Chinese. I don't know, like, forgive me if I'm murdering the name of the exact But yeah, so the documentation is more from the community out there. And I started to navigate into those waters when the documentation was not completely translated in English yet. But coming back to what we were talking about, where OpenSwoll locates itself in this context where we have FrankenPHP doing kind of the same. I would put in the words where OpenSuo accomplishes something that is an alternative to those. The way I see OpenSuo is that it's extremely fast, the API to work with it, which is something that might be personal. I feel it's Very easy to learn. I'm a native Linux user, so for me it was very natural to work with OpenSuo and to play. When I started, I started because I wanted to work with WebSockets within the PHP universe, something that was not very common. And I was able to work with WebSockets out of the box with no problem and deliver a lot. with that very fast. And that's what OpenSwap brings. And the other solutions, I think they are as good as— forgive if I don't have a better explanation, or if I'm not saying something that is accurate, but— No, no, no. But from the tests that I did a few years ago, when I first heard of those other technologies, OpenSOL was still the fastest when it comes to performance. So I don't know how it looks nowadays. It has been a while since I checked the benchmarks. But yeah, OpenSOL was like incredibly fast. So yeah, I would say that They are not— they are alternatives to accomplish the same things. OpenSwarm might have a few extra functionalities that I would say matters a lot to me, specifically when it comes to microservices architectures. OpenSwarm fits with a— how can I word it? OpenSOL fits very well in that ecosystem.
Scott Keck-Warren
12:52
Okay. Because, because you're doing like a lot of like, you know, especially if, if you have, you know, a frontend that's accessing a bunch of microservices, then you can do like that, that coroutine, right? I, I'm sorry, the, the verbiage is, it's lose, I lose it sometimes, but it's like a coroutine. Yeah. Um, cuz it, cuz like I also, like I also thought about like WebSockets as well, cuz it seems like you could have just like a ton of open connections to your server. doing this with this way because it's just, you know, it's so much less memory and not having like spinning up a million, you know, individual PHP processes. So, so like, yeah. So, so is there like, is it possible to run like, could we run like a framework within like the, the, like the little web server that OpenSwoll gives us? Or is that, is that kind of like outside of like the use cases for this?
It's totally possible. There are a few frameworks out there built in OpenSwoll right now. Actually, they I think some of them support both Swole and OpenSwole. I have to say that the interface differs a bit since the project got forked. So some of them might work on Swole only, some of them might work on OpenSwole. And there is even support for OpenSwole in Laravel ecosystem called Octane. So you can run your Laravel with Swole or OpenSwole. You won't have all the benefits that running OpenSWO from the ground up has, but you'll have a lot of functionalities available for you. Sidecar functionalities, for example, having a function happening in the side without necessity of queuing or dispatching jobs through schedulers. You can just use— multiprocess and coroutines by using Octane. But you don't have a WebSocket server, for example, in Octane. So they went into the direction of using Reverb instead, which is another part of the community that is building the same type of functionality, but with PHP without those extensions, like without that extension open source. Um, sorry, but I— can you, can you repeat the question so I can— Yeah,
Scott Keck-Warren
15:08
it was just mostly like, we were just— I was just wondering, like, can you— you can use frameworks is essentially like the, the gist of it, right? Like, it's, it's possible. It's just like not— like maybe not out of the box, but like there's definitely like functionality to be able to do those things.
Yeah, I— yeah, a few years ago I built a— I, I tried to build a framework. I ended up actually having it But I never reached version 1. And it was basically a framework that would be plugin-oriented. So, you would have the bare bones of a web server and add any functionality that you wanted on top of it. Like, oh, now I want a middleware. Now I want to deliver an HTTP page. Or now I want a WebSocket with authorization. Stuff like that. So then you would add extra plugins and they would work like a WordPress, but in the OpenSuo ecosystem, which is a bit— has a better performance. So, and I've been following the community for a while and I saw other people trying to build their own frameworks as well, which— and they look great. I have to say that. And the Svelte community, they also have a lot of, a few frameworks, very robust, by the way. It has been a while since I looked. I forgot their name, but there is one out there that is like very powerful. I don't use because their documentation is not completely written in English right now. And yeah, and I don't know for what reason I need a VPN to access the documentation. But they have very powerful frameworks built already with OpenSWOL, or dare I say SWOL, out there. So yeah.
Scott Keck-Warren
16:59
Yeah. I think it's really interesting because everybody's trying to solve this problem of lots of connections to PHP and handling tons of connections essentially. So it's really interesting to see the different ways that people have done that.
I would say that if you serve your application using OpenSwoll and you are able to do that, because sometimes when you're bootstrapping a project, you choose to use a framework like Laravel because you want to do it fast, you want to get out the door faster, right? But if you have the chance to use OpenSwoll, you'll see how fast you can make your service work. How can I word it? And you need way less resources to deliver huge amounts of loads, like to handle a lot of load. I would say that.
Scott Keck-Warren
17:54
Yeah, it's definitely like I'm not like in that mode of like needing this level of like connection, but it is like really fun to kind of see how it all works. So we'll be right back after this word from our sponsors. When your app breaks in production, you want to quickly understand and fix it, not sift through logs for the next hour. That's where Honeybadger comes in. Honeybadger notifies you of errors, outages, and performance issues as they occur and helps you respond instantly when your systems go down. You might need to dig deeper, and Honeybadger's advanced query engine helps you reach into your logs and grab just the information that you need. With error tracking, performance and uptime monitoring, log management, and support for over 10 languages, Honeybadger is the best tool to gain real-time insights into your application's health and performance. Best of all, it's free to get started and setup takes less than 5 minutes. Be sure to bookmark honeybadger.io. That's honeybadger.io. We're back with Savio. Um, so can you talk to us a little about, about your book about Jacked PHP, where you talk about some of these things, like what, why you felt like you needed to make it and kind of what, what topics are included in it?
Yep. Um, I started the project of writing this book back in 2020. I started to write it because I felt that the community was not completely aware of this. Everybody, like every meetup, every conference that I would go to, they would say, I don't know about it. Like, I don't know what you're talking about. I don't know this technology, what it is. At work, I would mention open source as an alternative, and people would say, I don't know what it is. I don't trust it because I don't know how stable it is, stuff like that. So, okay. Maybe what is needed is something more formal coming to the community, something that kind of like, okay, this is a real tool. It's used by a lot of people out there. Like there is a formal knowledge being built on top of it. People maintaining it, new versions. We are patching bugs. There's people able to give support and help with knowledge. So I felt this necessity of spreading the word, basically. And then I started to talk about it in meetups. I gave a talk in PHP Tech last year. I gave a talk about it. And finally, I got this book out of the door. I've been writing for a few years. And that's basically why I wrote it, is because I wanted to kind of help, because Also, it's very important to say, I believe that tools like OpenSoul, not necessarily just OpenSoul, but tools like OpenSoul that dares to make PHP faster, more robust, face new challenges out there, are essential. And I felt that OpenSoul took this step first.
Scott Keck-Warren
20:43
Yeah.
Scott Keck-Warren
20:46
Yeah, I definitely feel like there's, there's, there's just so much stuff like within the community, like all these little projects. So it's always like, even like, you know, like I had, I had heard of OpenSwoll and like known that it existed, but I didn't really even like get into it. So it was really interesting reading. I've only been able to read like the first like 3 or 4 chapters of the book. Um, but it's like really interesting, like just seeing like the bits and pieces of like, you know, oh, well, this, this is where this thing fits within our community and how like it can help the Like, you know, here I was like, okay, well, I can just, I can use this. Like I can obviously see like when I have, you know, 10 connections I need to make to an API server, just do 'em all sequen— or, uh, you know, asynchronously and then get the results later. So that, that's really like a helpful, helpful piece to that. So, um,
can you explain a little— You, you like further chapters when I start to talk about asynchronous programming.
Scott Keck-Warren
21:35
Oh, okay.
So those chapters are the hardest ones. Because you, when you're playing with those concepts, uh, then it starts the real challenge of understanding what's happening. And then I, I try to explain, but, uh, I, I already revealed a few of those after publishing, and I was like, okay, I'm having ideas for the next, the next edition.
Scott Keck-Warren
21:58
Okay, that's good. We— I had to go when I was in university, like, we had, we had a class where we had to do like multi-process, multiple, multiple threading. And it was always like everyone's head was just like swimming when we were trying to like figure all that out. So I, and like, it is a complex concept. So yeah. Um, so I have to ask though, like, why is the book called Jacked PHP? Like, I couldn't really figure that out from like the section that I've read so far.
Yeah. Uh, this is actually an idea of my bro— of my brother. Uh, my, I was talking to my brother and I wanted the name, uh, to this book that I was writing about. And he asked me, What this book is going to offer to the PHP community, as I said, it's going to offer a very powerful solution for the new challenges out there on the web. And these are more robust solutions that offer better performance, stuff like that. And that's how I put the words to explain and explain to him. He's not a technical person, he's a designer. And then he said, oh, so in other words, it's going to be your application, if built in OpenSuo, is going to be a jacked version of what you could build without it. And I said, yeah, that sounds like a great fit for what I'm saying when I'm not being technical. Like, it's a jacked version of what you would build because You could build without it and it will handle like this X amount of requests. If you build with it, you deliver, you're able to handle X times thousands requests. So yeah, that sounds like a great idea. And I kept digesting that for a while and then I said, okay, this is going to be JacketPHP.
Scott Keck-Warren
23:48
Yeah, that's a good way to come up with a name. I think it's really like a funny name, especially since now I know that story. It's really funny. That's great. So, is there any— like, the book is out now. It's available through the PHP Architect website. Is there anything else that you want to kind of talk about, about the book?
Well, I would like people to read it and to start discussing about these topics in community. I would really like people to start using OpenSOL or at least put OpenSOL as a comparison with the good alternatives that we have out there. As much people, if a lot of people get awareness of this, we start to bring this to more work environments. I had very little, very few opportunities to put this to work in my work environments. I would like to bring this more often as a good alternative because like having more people aware open the minds of the leadership in companies to use those tools. So yeah, like, people, read it and share your knowledge because this is very important for tools like OpenSwoll to reach people and solve their problems. And that's all.
Scott Keck-Warren
25:10
Yeah. I'm a big fan of, like, reading books for— in, like, technology things. Because even if, like, the problem that it's solving, you might not have now, but you might have it in the future. And it's nice to have that, like, in your back pocket to go like, oh, having a problem here. I got it. Yeah, absolutely. So I really do appreciate you finding some time to talk to us today. Is there anything else that you want to direct our listeners to? Like, do you have a website or a Twitter or anything that you want to direct people to?
Well, my website is my name dot com. So saviorisende.com. We can put in the description if you want. I would really appreciate people to, to learn more about what I used to I try to write at least once a month in my blog. I discuss subjects like microservices and different types of architecture. I've been quiet for a while now because I'm dedicating to finish my master's degree. But, yeah, soon enough, I will come back to writing more and spread more knowledge out there.
Scott Keck-Warren
26:13
Awesome. Then thank you for spending some— thank you for talking with us today.
Scott Keck-Warren
26:20
I just say another heartfelt thank you to Savio for all of his time and also for yours as well. If you're not already a subscriber, make sure you subscribe with whatever your preferred method is. And if you're listening to this, please make sure that you have the automatic downloads on as that does help other people find us. 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.