YouTubevideo· Aug 26, 2024· 9:36· 8,200 views on YouTube

It's HonoJS... but in PHP?

Watch on YouTube ↗
0:00

React at a moment you like. The best moments light up here.

transcript

23 moments
  1. so I'm trying to broaden my horizons I would say that I don't really know PHP that well I try to keep up with okay here's the things that are strictly PHP here's the things that are laravel so I have a little bit of Distinction but when it comes to actually like writing PHP code I don't necessarily know too much about how it works I came across from Jamie Barton who works at turo I came across a project that Jamie wrote

  2. which is Dumbo it's a lightweight friendly PHP framework for HTTP inspired by hono and I think this is a perfect project for me to take a little bit of a look into okay how is PHP actually work what are some things that I I would find interesting so think of this as laral developer who is learning PHP and you're on this journey with me okay because I have a bunch of things and videos and

  3. content lined up for just me learning PHP and just learning a whole bunch of different things for example like hono is extremely interesting to me I've used it on a couple of projects even before I started working in larel right when had just launched and I love the Simplicity that it brings in fact one of the projects that it has I don't know if I'll be able to find it maybe it's this H know

  4. examples okay here it is a cloud flare Prisma hono X starter the what got me interested in how hono itself is trying to to show it is it just looks really simple so an app server. Ts for example that's not it app we'll say it routes okay we have this index.

  5. TSX you have these uh cons to do where it's basically like a server rendered action but then you also have routes in the file so what interested me about this is I've always said that I think that's what people are looking for of I don't want to create a whole new file right now to do an API route when I'm just working with the data that were being retrieved

  6. usually in that same component it' be nice if I could separate this if I needed to but for now I just want it all in one file that's why I love live wire so much and so I think stuff like this is intriguing to me and I think this is what hono brings and so um having this Dumbo would be a great idea to say okay what what makes this valuable but so just it just looks really simple so we have this app git where we can just

  7. return some Json we can have specific routing functions we can return some text and some HTML or redirect so again Jamie wanted me to note that this is just a fun project to mess around with PHP so it's not anything that he wants you to go ahead and just break and and figure out but use it to learn PHP like

  8. me me so I've already built this project I have it running on Lille herd that's why I have that so let me just go ahead and open it up code SL Dumbo and we'll open that up in vs code right here we have this index.php file and here I scaffold it out like what like a basic templating system could look like but any new Dumbo

  9. initiated it looks like and then in the vendor Auto load and that's where you bring in specific files so this was interesting to me because I know this is how PHP and composer works but this is where it gets all the information for all of your vendor files in this case Dumbo right here is what's being pulled in and then you can have all this accessed on the page so when we have

  10. used Dumbo it's bringing this class in and I have I have PHP intelence in my vs code setting there's a whole video setup if you're looking for that's in the description below but I can just option click into specific classes so this is the Dumbo class the very simple PHP HTTP framework for we have a router we have

  11. specific methods and then okay so this would be handling the router we can run it gets the file for when we're creating new server requests okay you send the response to the client okay so all of this like makes sense to me like I understand like how a router and how you know how a server Works within PHP and

  12. again this is just all plain PHP that he has cobbled together into a simple PHP framework and then when we're using it we can create a new instant instantiation of this class I don't even know if that's the correct term for it new we're creating a new version of this class so that we can use so we have an app and a user the user is where we can actually get the routes so we

  13. have SL route here which is returning the Json of user data and then slash ID yeah okay yeah this is what I was trying to remember what I actually did in here so I have this post request for Slash and if I was to just comment this out and maybe return this instead here then in our browser refresh okay it's not

  14. returning let's see oh that's the post request that's why I need the get request let's just return some text and we can say hi there okay what am I doing wrong oh I remember yes okay so the way that Dumbo is set up is you can have nested routes I have this user that is in the

  15. app route users so if I was to go to slash users then I would see that high there so again this is very nice if you wanted to have nested routes I wonder how that's working app route okay yeah so this is the function route nested app get routes yeah so we're just taking any

  16. routes that we have in this user initiation of Dumbo we stve the get ID get post we all have all this for that user and then we just route it into the app route right here very nice and then yeah so we can use specific headers so we can set messages for all of our

  17. routes I believe let's take a look at the docs okay so that's middleware that's nice so we can anything in the app use is going to have middleware and I believe I'm still learning with PHP but I believe that it's top down so if I had app use above looks like there's two app uses here so I'm guessing it doesn't I'm guessing this one happens first and

  18. then this one happens second that's my understanding of a PHP would be and then we have the ability to redirect so yeah I set up what a very Bare Bones template would look like in this case we have a function render template I have this Pages index.html file where I just have this I don't know handlebar kind of syntax and it would probably be fairly easy to get Blade up and running within

  19. Dumbo but what we're doing here is we're just taking that index.html file right here and we're passing it into that render template function so we're getting that template path we're getting the data and we're just going over and replacing information in this case we have our data and passing in the title heading content and items that is just

  20. being passed into this index.html so again very Bare Bones templating system but I thought it would be interesting to take a look at how that works so yeah take a look at Dumbo it's one of the things that's helped me start this brand new journey of okay what does it look like to actually know PHP I was to say I want to build this project just with raw PHP would I know

  21. how to do it currently probably not but this is helping with that itch and it's just helping me learn more about the functionality and components that PHP has all together it's helping me fall in love with PHP a little bit more actually I used to not like the syntax as much and now it's it's growing on me that's for sure maybe you're like me and you've run into a couple different projects like Dumbo or hono or I'm going to take

  22. a could look officially on video for Phoenix and elixir and even python maybe I love learning things like this so that one it helps me appreciate like how I just have accumulated skills over time to build the things that I know how to build within a framework like larl but then two it helps me also just learn more it helps me learn how to build specific things that I wouldn't have thought of it helps me take those ideas

  23. and put it into how I'm building a project in whether it's any of these things check out Dumbo but keep building keep creating

just you here