Adding a new feature to Laravel Valet, with Marcel Pociot | Matt Stauffer Livestream

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] share screen with skype i'm going to say hi to all the twitch people but i y'all this is the first time using restream to stream to youtube events which is their new thing and it's looking right now like restream is not correctly sending to the youtube event even though it says it is no it does there are two streams yeah there's one scheduled stream oh goodness and another one that works okay so we need to um put a link to the one that's working in the ones not working then huh okay so that's frustrating but that explains why yeah that should be the right one great so i'll copy this one and i'll paste it to the other folks sorry y'all looks like restream created two streams here's the right one okay so hopefully that gets everybody from the wrong one into the right one and i can feel bad but whatever that is life all right so i believe we're now live on twitch before we see anything else everybody can you hear my audio and marcel's audio correctly it takes them just so you know marcel takes them about eight seconds to be able to hear it get a little bit of lag vince says yes great all right hey everybody um so let's pull up our episode notes for this ones we are about to just write that right out what we're doing all right so uh if you've never showed up to one of my streams before welcome nice to see you all again if you have um thanks for hanging out again i'm a bit low sesame software okay um i might just not be on my mic enough um okay let's see if that helps um and this time wonderfully i'm joined by my friend marcel so marcel would you say hi to anybody who has not actually gotten to know you before yeah sure hey uh everyone on twitch and youtube yeah it's cool that we can do this together and explore the wonderful valet some more yeah we got some fun plans for today um yeah so the reason that we're doing this stream in part is just because marcel's great i like him and i've been wanting to stream again for a while but because of the pandemic uh i was really not able to do anything like this with kids schedules and everything like that um but also marcel was talking to dr bite or chris and me and just saying hey i have some ideas for valet do you guys have time to work on this and dr bite has been probably so i'm the maintainer of valet meaning like i'm the person who you know handles the pull requests and the issues and stuff like that but chris has really been the person who understands the kind of the guts the internals of valet better than anybody else for a w for a while um and so we said hey chris is this something you're thinking about doing he said eventually but i'm pretty busy right now so marcel and i said you know what we're going to do we're going to take these two big ideas that marcel has and we're going to kind of try and do them ourselves on a stream and see how it goes so we have a couple cool ideas that we want to work on and um marcel since you were kind of the one who came to us for these two ideas why don't you kind of introduce at least the one we're going to start with today and maybe you can give a quick preview of what the next one's going to be too yeah sure so the the first idea that i had was that it would be cool to have kind of a default site in valet that would get returned instead of a 404 page so i could visit whatever site and then get this default site but instead of only having a customizable 404 site this could add some logic so for example you could see all your registered sites maybe informations about those sites so sort of like a ui kind of four valet that sits right within valet as a fallback so that was uh the one idea and then i don't know if we have to dive into this as we as we do this but um the other idea would was in valet there are currently already extensions so you can add custom code to valet but the way they work right now is just you have to copy specific files into the dot valet extensions folder so it's not super developer friendly and i don't think they can do stuff like add custom commands or anything like that so the ability to just customize valet some more with extensions that uh in best case can be installed by a composer it would be the other idea yeah and when everybody saw that it was going to be you and me streaming together in valley of course the first thing they all said was valet and exposed you know is that going to be the thing and i think it would be totally a reasonable kind of first plug-in would be to make a first-party you know valet share equivalent that ends up using expose instead and if anybody doesn't know martial created something called expose that's basically a php power powered version of the same thing of what ngrok does so right now valet share uses ngrok to share your site publicly and you can use expose with valet already but if we were to build it first party you know well third party but a third-party integration that puts it directly into your valet commands that's something we could do that'd be pretty cool too so today what we're the original goal for today was to say we're going to make a default slash fallback site for valet instead of 404s um i'm sorry to anybody who missed the first 12 minutes but the good news is the first eight of those 12 minutes was literally just us trying to figure out why there were two streams so you just missed us saying what we're going to be working on is what i'm writing right now so um and then make the um that site configurable by the user um and give access to a list of registered sites the tld and anything else interesting to that site so this morning before we started i was doing a little bit of digging around trying to figure out where we would put this uh functionality and we discovered that this feature actually already exists in valet and it was added to the documentation as recently as one year ago however it was and this is uh this is marcel's discovery it was added to the six dot x documentation right before laravel seven released and so it never act actually one day before yeah one yeah you say one day and so because of that it would um the the seven documentation had already been forked from the 6.6 documentation so it never made it into the seven documentation so part of what we want to do today is already done but that's fine because that means we're more likely to complete what we want to do today in the span of time that we actually have available to us so we already have this concept called a default site that and i should look up the name of the person who originally um contributed it but this is where chris added the documentation where all you do is basically in your config file you add this default and then you can say here's my default so if i were to go and just basically create a new site and i know that my um sorry y'all know i know that my um terminal is always too small for streamers so let me just fix that real quick all right so if i were to come in here and i were to go to this and i would just say you know make dur fallback cd fall back and then make dirt public um and then touch index.html and then hello world okay so that would be my fallback site so right now if i were to go and just say blah blah blah blah blah.test you're going to see us 404 but if i go to my valet config and i hope i have the most update version on this machine which is going to be vim so it's going to be dot slash config valet config.json and so i would go in here and i were just to give myself a default and i would just point it to any directory in my entire computer so user slash matt stouffer slash sites where do i name it default or fallback a default folder yeah yeah so if you come over here we're now going to see hello world so that that bit of functionality actually already exists which is kind of cool because that means if we go back over to notion this is already done um so we had talked quite a bit about um so marcel's original idea was to do it exactly like this where every single person can park a specific site here and i was like oh that's going to be work we're going to have to add it to the config why don't we make it so that whatever site serves at valet.test is just your default and he's like okay but now this is already you know this already exists let's just use it this way right so everybody who has valet that's at least within the last two years already can make their own default or fallback site which is really cool because you know how like people would always do these things when you create a new tab it shows like your favorite things or whatever well oh man um santosh could you go to the other live stream link and just ping all them in a comment and just remind them that there's a different stream um i'm hoping there i also tweeted out the correct link thank you i don't know how to go stream to there as well um i'm i'm assuming for anybody who's watching the live playback after the fact i'm sorry that we're putting you through this but i i want to make sure that those people aren't just sitting twiddling their thumbs let me see if i can real quick switch to [Music] that one will it let me go live on the wrong one basically y'all can see i i watch lots of adhd and tiny desks um i don't know if it's actually gonna let me just kind of like go live over there and say hey everybody we're doing something else so hopefully they'll all check the chats when you all did to do that okay cool so um so yeah so this is a little bit sort of like hey you know when i create a new tab show me this one thing well we can do this thing where you know you create a new tab you know just type whatever that test and it's going to show your stuff there so you could just make this a list of your favorite bookmarks or what the site you're currently working on which i think is kind of cool the original proposal pull request actually suggested the idea of making a command that you could use um to set this one the reason that they ended up deciding not to do it is because there was not great my link didn't show up in the chat for some reason okay but ms offer you did put the link hopefully that'll fix it um so the originally hey nuno um the original problem they had was um somebody else joined us like no hey kristoff they couldn't come up with a good command for it so they were looking at things like well if it's going to be valet because it was originally called valet fallback but they changed it to valet default and one of the things that adam kind of mentioned was if you say valet remove default or default removed just seems weird because it's not really kind of the most reasonable thing one thing i was thinking about is we could potentially bring it back but have a different syntax where it's going to be something where instead of remove it's going to be like 404 or something like that so we could potentially talk about um maybe bring the command back but for right now if somebody wants to do a fallback site again you just edit this file dot config valley config.json and you just add a key name default and then just point it to a site so obviously people would use it a little bit more hey kai hey ryan hey oh yeah that's the only people so if we could add a command um you know that might make it better some command syntax um so it doesn't doesn't require editing config.json question mark um so for everybody who just showed up we had the idea of making a fallback site so when you type an unmatched site into valet it still shows you something then we discovered early this morning that that feature already exists but it kind of slipped through in the documentation so it's in that six dot um x documentation but not in the seven and eight i was originally thinking why don't we pull request it here but i kind of want you know what we could do i was gonna say i kind of want um dr bight to get uh credit for that but we could just pull request it seven and eight right now and add him as a co-author in git github so um but i do think that updating documentation is maybe not the most interesting thing to do in a stream so let's do it later uh hey deb jeet um so i will say um pr the same documentation into 7.x and 8.x so um can you provide a valet valet default so that way no command is required since it exists uh native that's pretty much i guess what what you wanted with the default valet.test site yeah yeah so my original idea was that there was gonna there's gonna like when you first go to the website there's gonna be a valet.test um and then whatever serves from there so you're seeing this right here because i happen to have the valet app itself in here but my idea was there's gonna be a valet.test which is the default that ships with it and then if you want to connect it you get that and i think that that's probably something what we should do is today what i'm thinking we do and i know i'm jumping around a lot everybody what i think we can do today is make a site that we like that we think makes sense to have as the default and then over the span of the next you know hour basically say do we like this and then we can put it up as a proposal in the the issues and just say does everybody think that this is a good fallback or is this more something that only some people are going to want because what we don't want is for people to see it and be confused about why it's there especially when they're used to a 404 right so i think what we can do right now is just say why don't we imagine what that site's going to look like because marcel had some ideas about what that site could look like and why don't we kind of start there right and try to look what it looks like for that site to be useful meaning it actually can consume some things from valet like the list of paths we have available to us and then from there you know decide whether it should be the default so so far we have the idea of all the sites that are parked or linked the tld is there anything else that you marcel or chatters any of y'all would really think would be relevant to have on that site i think it really depends on how much we want to add there um i started working on this valet ui electron app and i think there is a lot of overlap of what we could achieve in such a default site so for example we could show all all sites that are parked and because we know that this is a laravel site where this is a wordpress site because of the driver that they use we could show different information um on those parked sites for example allow users to with click up the button connect to table plus and open the database if it's a laravel app or stuff like that or um yeah i think it really depends on how far we want to go there right and christoph said which side has ssl yeah yeah it would be nice yeah yeah so in the electron app i also had a button where you can say secure sites and yeah and then it would just yeah do this because i mean these buttons could theoretically just call um you know command line valet calls themselves right yeah all right that's a that's a cool idea ms offer um so if i type in you know i'm off by a letter or something like that um we can maybe propose similar yeah did you mean whatever [Music] um this would be a link trying to remember what else the other contextual menus you suggested or a link to open your uh cool so there's a lot of cool ideas there um i love this so what we want to do is recognize that this is a lot of high level information that we want to be able to get out of valet that right now valet doesn't expose as far as i know in jason so i feel like the first idea would be to either recognize that somehow we're going to make all that information available to every site um that we serve or we have to make this information available out of json out of um so hold on let's actually write this down so question is basically how does all this data become available to the site so i was thinking one of the questions one of the things could be valet command exposing all this data as json right it's literally just like something like valet i don't know uh list json or something like that right and that like gives you literally everything you need jason and anybody else can can do it um oh yeah that's a great idea john sugar says um show am i up to date um so it's not yes yeah valley specific information am i up to date on the latest version all right so it could be it's not officially available for windows um but there are forks for windows and linux and i would like as the valley of maintainer i would like to see it working for windows and linux eventually as as first party support um but uh that is going to be a little bit more in the plate of dr bite chris because he's the one who has to deal with that more than me i have i have dreams and he has the ex he's i'm like the sales person and he's like the coder so i can't promise it but i like the idea a lot of everything we make being a being functional for windows and linux so all right so we could have a valet command exposing this hall's json or we can make all this information available somehow to every site which seems kind of awkward to me because you know every site that um valet serves kind of goes for the server.php but the thing is how are you going to make this much rich of information available to every single site that serves like it's not like you can have the app container and always buy it in the app container or something like that they might not be a laravel site so i don't really know how you do that are there any other ways we should be considering for this what i thought is so if we have this default site it could just be a like a level app if we think about it that has a composer require of valet itself and then we just use the valet class that already has methods like i think get parked or something like that and then we just use um that internally um so we might have to make those methods public or something like that depending on although most of them are just functions they're not even classes or anything like that yeah i think there's there's like a facade kind of going on in ballet i mean that certainly would be the easiest one because it doesn't require any changes to valet so maybe we start there this is why i should yeah i think you'd talk first sometimes yeah i think it depends on how we want to distribute the app because if we we actually plan on on adding it to valet at some point this probably wouldn't work because as you mentioned valet still needs to support php 5.6 so if we would decide to create a default laravel app well we need to go with low version if we want to do that and i mean in there are people who expose their entire valet out to the public which means i don't really feel super comfortable making a default laravel app that um that isn't security fixed so yeah that's good also stuck really depends if we want to ship this out of the box or if it's something that you have to opt in and say i want this default site i'm more inclined to say let's build it now and if we decide in order to provide 5.6 compatibility we have to make it not a laravel app in order to make the or somehow really lock it down or something like that then we make that decision later because we only got an hour you know what i mean does that sound okay by you right sure so i would just say let's just make a laravel 8 app and just kind of just call it there um okay so uh kai had the idea of um putting in what php version you're using and what version a given site needs which is i think is really cool um so let's um uh show which php version it requires um i think this is all really great stuff and i'm really glad we're doing this on a stream um okay so i think that our steps to do right now are make a laravel app require let's say laravel 8 for now uh will downgrade if we decide to ship this out of the box thanks andre um out of the box and require valet and see if we can get the information we want um out of that hey joseph i missed you all too and we've got marcel streaming now too which is awesome i'm really excited marcel is one of the most you know i think he may be the most prolific creator in the entire laravel ecosystem maybe maybe other than taylor um and everything marcel has ever made or done i've been a huge fan of and so i'm happy to call him my friend but i'm also really excited that you all get to to kind of share this goodness all right so let's make a new site um so it's so funny as the person who maintains lambo my lambo is not actually um up to always in a state where it can be used helpfully because it's always like in the middle of features but let me see if i can make sure lambo is in the most it's probably in a beta or something like that um okay cool so let's try lambo and we'll just call it oh i already had fallback oops lambo new fall back in the new one um in 404 page not found you want to initialize that's an interesting idea the only thing with that is initialize could mean a lot of things i wonder can you do a button link that opens something in your terminal um [Music] so in the in the valley ui app there's like a add site button which would have like a modal where you can create a new valet app uh a new laravel app and then choose well that's it jet stream so maybe that could work as well oh yeah no kristoff he definitely does i don't know do you have a dog marcel i don't think you have a dog right yeah you heard it you heard him yesterday oh yeah you're right you do have a dog i did hear him yeah so no he's got everything y'all people are trying to figure out how you're able to do so much i do sometimes yep all right so sorry you were just talking and i was being distracted by people trying to figure out your dog can you tell me again what you were just saying so we could add um a button that yeah open up a modal or something where you can create a new laravel app but yeah i don't know if we want to make it that laravel specific i guess most people use valet with laravel but i mean it works with any app so yeah so that's that let's just call it an idea um cool um all right so lambo just did its thing so we've got it open vs code and we've got uh fallback.test i don't know why it didn't open that for me i probably have my things that weird okay cool so this is our fallback.test so we are going to try and compose or require um laravel valet and can everybody see that font size okay oh christoph was joking sorry i just it's so hard for me to go back and forth between things oh geez all right um so we've got access to it so let's imagine we're going to build something really simple hey andre what's going on man hey tim um oh we don't have home controller jeez i'm so not used to what it what it's like when you don't have auth um built in out of the box okay so let's just do it all in here we're doing it live and so we need to be able to get our list so first thing we would want to do what's the simplest thing just get a list of linked sites right because then we don't have to deal with the park so for anybody who doesn't know there's a difference between link and park park is serve everything out of this directory link is i want you to link this very specific directory i don't think i actually have um anything linked can you even figure that out in valet is valet itself what you mean which sites are linked yeah i feel like we yeah we do have it valet links yeah we have that somewhere okay so yeah so i don't even link so let me link something really quickly i think i can link something even when it's linked already linked but let's not do the one we're in right now so um let's link symposium um i'm trying to remember there's what the syntax is for valet link oh okay easy enough okay cool so valet links should now give us something yup okay so i think the simplest thing for us to do is just get all links so links equals something so if we were in so let's open up valet over here um hi dustin all right so in valet let's look up commands for links so if anybody's not familiar the way valet works in general is that you've got the server.php and the configuration that valet exposes um is uh in in here and basically what it ends up doing is looking up your file your configuration file and then this basic version what app are you trying to get to based on like your configurations and based on the url that you're passing in it looks up all these configuration paths to figure out like should we be you know basically which sites are actually sites and all this kind of stuff which ones match it and then if nothing works it shows the valet 404 if it does work then it ends up figuring out which driver are you going to serve it with and then it loads the environment variables and then it actually basically passes it into that one so all of this is where it's actually happening but it's taking advantage of other things that are happening outside of here so you can see all your drivers in here which we're going to ignore right now you have some helpers and i'm trying to remember so the stubs these are all for like setting it up for valley install so we don't need that right now how are you able to stream and not have your computer grind to a halt um i have an imac that's the only reason i'm able to do it um i bet you the m1 could do it but my old computer couldn't do it at all but all the actual php classes live in this valet thing so this is where it actually gets into what you're much more familiar with and so this is where the majority of this is more the stuff that chris dr bite takes care of not me so i'm actually just gonna go and just see if we have something named linked um i think you can take a look at the there's this lowercase valet.php file okay is that where the commands are registered yeah right yeah so yeah you're right of course look for links you should see what's being called under the hood there we go all right site links good call and so it makes a table which is just a helper that basically gives you this kind of output right here with a site ssl url and path and then you can see that and links all so this links is going to give us an output that has basically probably a collection of some sort um and so let's go take a look at site links uh okay can the font be a little bit bigger it certainly can is it uh let me know if i'm saying it wrong um dustin says m1 can definitely handle this kind of streaming which is good because i may stream from my office where i work with my this is home this is my home office but i'm just starting to go back to the office again and i'm going to be taking my m1 mac over there so all right so oh sorry i tried to click on that and it didn't work so but it was site.php that we were in um i got his name right great thank you all right links all right so um it gets certificates path it gets all this okay so the good thing is everything in valet is written without um public or private so all we have to do yeah we don't have to worry about that um all right one fault font size smaller is fine is that still from adam it's just from adam yeah adam taylor wrote it that way so we do have to new it up with a configuration command line in the system so we've got to figure out where um site is actually newed up and kind of figure out that flow right there um hmm yeah i think i think there is like a facade oh is there a helper or something like that um yes the only time they're actually doing it like that i did switch to a light vs code theme but i need to do something where i get a dark one at night because the light one at night is awful um okay so we got to basically figure out where site is instantiated so we think it's probably going to be oh are they facade no it must be a facade right because yeah i think if you take a look at the valet.php you should see something so yeah so it's calling me anything so you think that's where that facade thing is happening oh it actually has like a yeah oh cool right this is awesome so this is what it is right now so when it calls this but this thing oh it's actually got a container so in theory you can see how this works with laravel let's see if we can just use it straight out of the box then so let's um make an instance of site and just see if laravel can resolve it um and then i'll probably use ray in just a second fire up the editor and knight eyes immediately combust exactly um so keith who works at titan he has a keyboard shortcut for his sublime text and at night he hits that keyboard shortcut and it switches the exact same theme but dark and i need to set that up for vs code for sure all right valley requires homebrew to install in your mac okay which it is um but we're gonna have to figure out where those tests are happening um all right so if exactly well that's weird because that should still work right so this this happens right out of the autoloader right yeah yeah i mean i feel like if i if i run that right there you should be able to um oops you should get an answer out of this uh did i do something wrong yeah it doesn't even hit that because oh that's what you're saying okay got it sorry files are yeah right um okay and valet wasn't ever intended to be used this way so okay so let's just take a look to see if there's an easy way for us to maybe do a change um uh to the autoloader so let's figure out on your compatibility is that being pulled in by um composer jason i guess yeah all right yeah so let's just take a look here real quick um oh cause i'm editing the wrong one i need to edit the valet that is in the vendor director all right this one yeah all right all right so we are in fall back so vim vendor laravel valet and then was that in scala helpers i wasn't cli uh oh uh right there's an extension for auto dark mode i did not know that i i'm going to switch back to php storm eventually everybody i promise i will wow how is that happening oops is valet serving something in a context where which is like different how does it not have access to which brew maybe because of the php any that that you are not allowed to call which from the fpm context you're right paganovich i did try that um i mean maybe jeez huh it knows who i am it's serving from the directory i'm expect expects that i'm serving it from and yet which brew is failing well let's let's start right now by just imagining we do a pull request here that says um uh so let's take a note here so we don't forget um in notion um pr valet to allow compatibility check to skip which brew if you're in a laravel app including it basically something like i mean we would yeah basically we could skip the whole file if we are not in cli mode oh yeah yeah do you know the syntax for cli mode of top of your head i never remember it no okay let's just google it i know the standard concept i know this one right here i kind of thought there was a newer one i think the phps api name yeah i knew there was a better one all right so i'm actually curious what sapi name is when you're not in cli um let's find out i'm also probably about to switch to ray i guess it's something like oh okay got it yeah yeah um kristoff says oh kristoff is going to give me pressure by giving access to his uh php stormcard i really will switch to phpstorm i promise i i apologize to caleb when i asked something about um uh vs code the other day because he was like that's in my course i'm like the only reason i haven't taken your course is to try to switch to phpstorm hey blake.js uh yes dustin you're exactly right okay so we'll basically just say return and which and this is gonna say um allow um bypassing these checks um if using uh valet in a laravel app well just a non-cli app okay and so let's copy that actually and just um somebody says started the stream with vs code promises goes back to phpstorm currently using vim yep all right so let's copy this and throw it in my valet real quick um gc so i'm gonna make a branch in valet called allow use in um non-cli and in that version of it we're gonna do that same change up here so that we don't forget it later all right so in theory this should now give a blank page at least yeah so that's weird why is it is it running twice constant valet home path already defined that's not yeah because it's being served by valet oh geez so your server php has it so we would also have to on but if there's only two such errors we might be okay right so let's yeah again let's let's just dive here for a little bit all right so oh all right so all of these would have to be if not defined already it's weird we're not getting the error on the other two right why are we only getting home path in static prefix not loopback and i don't know um so for right now let's just hide those and then i'll put a note in my uh version we're doing here that says oops i'll only define these if not already defined okay okay so we're dumping and dying on probably exec brew which brew so let's go back here and let's try again yep hey cool all right so it was yeah so i have one site all right that's weird so we're getting i know i already refreshed please oh it was so this is all it's yeah this is a side side links links i guess site links i just totally forgot they're noticing i'm using them key bindings in vs code hey so this is the information we need look at this this is freaking fantastic you were absolutely right that this was the best way to do it um okay so let's real quick make a um so we can do this we might actually let's see um so is there a way to see all your parked sites in valet or only just i think you can only get the folders and then oh display all the current sites within parked paths look at that oh cool okay hey i love this all right so um so let's go over here let's go to valley.php and then let's look for command parked and it's site parked look at this all right so links is that and if they're let's see if they're the same structure too um so we want a site instance and then we want to get all off of parked so let's do site link what was it links all links yep and then site parked all was it linked probably uh no it's a method oh lynx method and a parked method got it look at this this is freaking fantastic so we're going to run into one problem here which is that i um have sites here for clients that i'm on your nda for yeah so i need to censor it real quick everybody and i'm going to um take a look at what all i have here to see if there's any on this particular computer that i have to hide for that purpose there may not be um hey from malaysia hello back to malaysia all right let me just real quick look can the site class be dependency injected into the function yeah we could do this thinking about doing that they're just pulling everything out yeah we're just getting it right now yeah go ahead marcel um i don't know if i can have all of these but i bet you this is a collection so let's just say um let's just pull three of them let's do um audio visual and check well i gotta do one audio visual is a laravel app and field goal all right so um thank you so much samuel um okay so i learned to cut my own hair during um pandemic so what we're gonna do is i said audio visual what was the other one i said what did you do symposium okay so i'm gonna uns unshare now i'm gonna drop the sensor um oh thank you for hosting my stream felix all right so um is there porn now that it was um uh specific stuff for my clients so what we're gonna do is thanks ant um yeah i've been fading my son's hair for a couple years so i finally decided to try it on myself um okay so what i'm gonna do is when we deal with the parked ones i'm gonna filter them down temporarily so that i don't have to worry about accidentally revealing stuff so let's do that right now so linked equals site links all and then parked equals site parked filter or can we do wherein now whatever let's just do filter oops and then and then so for this i want to do return site uh sorry y'all i don't remember what the um the key is i think name gives it the same thing it's the key but it's also a key yeah capital s site no lowercase that's saying all right so site site um actually we'll just do an array yeah um and then audio visual symposium and then now we can you know let's ray real quick um so rather than dumping and dying oh i don't have rain this app okay we'll just stick with dine done for now okay nope still showing everything what on earth is going on i'll have to come back you're not dumping parked oh jesus and then i switched to ray okay thanks all right so we need linked and parked yep all right interestingly you don't get parked back if you've linked it which i did not know you see that symposium has been linked so it's not showing up in park either right miss type symposium here no yeah so let's add another one um sorry to keep censoring everybody i promise i'm gonna stop that in just a second let's see what's another site i can um that's an actual laravel site um ram on web yeah ram post it let's see if there's anything else in here i'm trying to get like different versions of nova packages no packages oh chrono be good because it's on a really really really old version of laravel all right uncensored okay so now let's see great okay cool so we've got all our sites and i bet you they all have the exact same structure site secured url paths so we can just array merge those um so but we might want them to be a little different so let's let's imagine we're going to be have them different right now so let's return view um home and then just pass those in uniquely for now um and so we'll say links is linked and parked as part while i'm doing this marcel should we do anything else before we build out a really rudimentary view i don't know if that's already too specific because i mean theoretically you could have one site that has multiple links so actually a link is kind of a relation so let's go back to symposium and let's do another link valet link so do you know what the syntax for link is off top of your head yeah yeah it's just the name of the the site that's what you want to see so i can do symposium app because the the live set is actually a symposium app so now we're gonna have symposium linked twice great call uh pull on a turtleneck and pull the sights out of of course that's um yeah sorry i'm doing like 10 000 things at once um what else do i work with besides laravel um view react view native script react native basically we used to do um like expression engine and stuff but not anymore oh you craft cms and static nice to see which ones are linked and which are part yeah that's why i'm sending them through as separate separate arrays so we can have the linked in the park separate so we have symposium and symposium app which are both the same site they're they're different sites in this mindset but they're served from the same app so that's a great point yeah so they have the same path yeah so we need to treat those in our minds as the same thing with different aliases basically right yeah right okay so we should probably do some work to join them before we pass it to the view so we want to group by i think um and you know what we don't have to all them we can just keep them as a collection now i think about this i still find it a bit weird that symposium doesn't show up for the parked side me i thought the same thing i kind of expected it to be there i don't think that valet is actually filtering them out at least i wouldn't type it wrong s-y-m-p-o-s-i-u-m let's you know what we can do we can do um i can do a post-it link and see if it disappears from right here yeah and it does wow it must be filtering and had no idea okay all right so um what is erroring here no call to dd okay got it um all right so um so i wanted to group it by site what was it path or something yeah and then now let's see what we get so this should now be one the symposium and then it's got two entries into it which are its two links perfect great call on that marcel um so we might want to do that for all sites right so we merged them first so we have them all in the same structure well we're gonna we're gonna display these a little differently right because all of the park sites well i guess that's a good point um so we can group these by their path even though they're um they're just gonna be uh yeah i used to create laravel nova packages i have uh to be honest i still need to take a look at the whole maintenance stuff uh we're just doing so much uh so yeah i haven't haven't done that in a while and i also haven't created any new ones okay so yes so now they're now all the same shape good call on that even if we um display them in so different spots so yeah um okay great um so okay go ahead if we if we start with the view now maybe we end up being lost in in ui niceties yeah i agree yeah yeah i mean maybe we could just take care of one object that holds these sites uh that has this functionality that cluster so for example so go ahead yeah yeah where we can for example get the linked uh or the used driver i don't even know if the current site uh in valet provides this but so then we have one object go ahead yeah where we can pull in some of the information that we have in this notion list that we want to show at some point yeah i love that so um uh felix says would it be better to merge them before the group buy the reason not is because i do think that in the view we may want to differentiate links versus parks so i think right now i want to keep them separate um all right so we need basically a an array well i don't know if it are these arrays yeah they're arrays no they're but only because of the all yeah so it's really going to be a path and then a collection um so this is going to be links right and path will be a string and links will be an array or a collection can i do this i'm trying to remember what the what's the like that is that how you do it with the new one apparently not something doesn't like this can you not do that isn't there a way to do like um union types in php now maybe i don't have the right version of php yet running locally all right so anyway we'll just keep it like this um so we want the path so this path equals path this links equals links and i'm not going to use php 8 syntax because i know i at least want it to work on older versions of php um so if anybody sees me using like php 7 syntax stop me because we want to keep old school stuff cool yeah we'll definitely talk about creating the ui at some point all right so we have uh this sorry protected path protected links okay so youth said some useful things we can do we can say uh like something like which driver it matches yeah or like get minimum php version what kai suggested i'm just wondering hey anna should we pass in the string of the path and the array of the links or should we path in the site objects from valet because i mean we're just converting it to an array because of the all right here but yeah but i stopped converting it to array you notice we're not doing all anymore so this is actually what we get back which is basically a collection with um or sorry so the item itself is just an array yeah okay yeah okay um so felis uh i would say if y'all could stop me using php7 and php8 syntax i'm going to try and write old nasty php here um so that if we do need to move this back to php56 it can still work so if you notice me using it please stop me um are there actually any usage statistics that general off of how many people use valet in 5.6 no but i can tell you from our issues that there's still a lot of people because anytime something doesn't work on php 5.6 people will say hey i still have to maintain this whole php56 app and i love valet can you help me out so i don't know the statistics but those people are vocal enough to actually come on the github issues and mention it so but i i might be willing to say um i think you can use you can use short array syntax and php56 can't you i think i i'm pretty darn sure you can yeah i was introduced in five four um so i i'm i may be inclined to just say hey y'all we can um you know if you want to use this particular site it's got to be when you're on your modern php versions because even those folks who have to maintain level five are like php five six apps they don't necessarily do it all day every day so i'm okay if we end up having but let's just at least not use like fancy 8.0 stuff um so okay so you were just saying let's build this thing out so we've got the driver we've got the minimum php version is there anything else we want to oh is is secured right yeah is there anything else we had talked about wanting to build out here on each one um the driver php version secured and then the contextual we can build out later okay all right so let's think about what's going to be the easiest to figure out so this right here is going to be um us actually finding it basically right like um yeah jason the secured one should be the easiest because i just looked at it if you type valet parked which you shouldn't to not show any sites again but there is like a check mark which shows ssl yes or no so it's interesting because it should be in the array actually a site isn't necessarily secured though right because it's a link that can be secured or not so you could have one of your links secured and when you're not secured so i feel like a site we might have to make a first class object for a link or something um and many sites will only have one link um and we'll just call it link right now and figure out where we're gonna go yeah the the feature that you can secure specific links actually has bit me recently because i was just calling valet secure and i expected it to secure everything but it only is if you just call valet secure it only secures the latest link got it um i don't know i i guess you can call valley secure and then pass in the url or the link so it secures that one but i'm not sure these links almost at all so i'm not actually sure kai is watching my telegram and message notifications go up over time all right so this is going to have an is secure um and then this is going to convert all of our links into links so we can do collect links map link return new link link how many times can you say link all right so this is a collection of links this is a string path is secured will not be um map into you probably can map into i've never even used map into just map into just let you say a class and that's it if so i love it i hope so if so thank you for teaching me something felix um all right is it would you say is secure or is secured probably secured right secured yeah okay our new master sword i want to play some zelda now [Laughter] okay so actually you know i i think once we have the link i want to extract it out so let's what are the things we have in the link um we've got site secured url and path so site url secured isn't that what we oh yeah if you want to pass it in yeah right oh there it is oh i haven't seen that okay okay and i honestly might make the constructor require all four of these and then just make a static constructor from array or something like that but right now we don't need to worry about it too much so we've got site um where's the next one secured we also might want to convert that to like a boolean because right now it's obviously not path can you provide something similar to titan slash checkmate can you tell me more about what you mean by that um okay so um items i'm going to find one that's secured x with the space before yeah with the space in front of it because it's formatted for a table but that's okay we can work with that um so we can say link secured um is empty basically right oh is it not is empty it's empty there you go just empty yeah oh john is saying can this thing itself oh that's a great idea so for anybody who doesn't know check laravel do we have a checkmate that's live that is publicly accessible i don't think we do because again it shows a lot of stuff checkmate is something that checks all your level app dependencies and tells well at least their level app versions and later it'll check their dependencies and it says for all of your sites that you have registered um it's on laravel 6.2 you need to upgrade it to 6.5 or it's on 5.6 you need to upgrade it to at least whatever so it's sort of like that laravel version site we made but for your specific apps and so he's suggesting can we do that in here which i think is a really great idea thanks john um that's like definitely advanced stuff but let's just put it in here anyway um uh like checkmate let um is this laravel version still secure up to date yes should be only one bang you're right thank you for catching that not empty not double not empty um this is why we stream this all right we have about 20 minutes because i got a call right after this um so we can just say this secured okay so minimum php version we'd actually have to dive into the stuff driver you want to do driver next marcel or is there something else on your mind yeah yeah i think driver should be easier all right so in theory with driver we're reproducing what valet is doing in server.php which is yes so i guess we have to loop over all the drivers but we would need to do this probably for all sites so for every site we would need to check all drivers and see which one returns true first okay it looks like there's a method for it valet driver assign and that does the work of looping um for one so if we were to just um so valley site path site name and uri it requires you to bring in this which apparently is not pulled in by default so we might actually have to pull this in ourselves we'll see um i mean we wouldn't put it in here but so valet site path is going to be um site name it's kind of surprising to me that it cares um yeah but it's um gonna be something we can get out of the first link basically this links first name which means we need to make all white links uh because the site doesn't have links well if the site doesn't have links then it doesn't exist right because in here we mapped all of our um all of our parked ones into the group by path as well so every everyone that's group so let me let me show you links is basically um so these are all structured the same right path and then this collection right here is links so when it's parked there's only one link right but that link is still the only way to get the site name okay um all right so we've got name you know what we could do we should we should put we should we should make things for this because we're gonna that's not the only time we're gonna be able to need that so public function name return oops this links first name and then on the link we also need to make methods for those oops and then we want secured we have we've got url and then path and what is site that's probably the name i guess so it would be oh oh oh oh so site okay so we've got site url path and secured kind of makes me want to just do this as much as i like fixing mine with is it's just because it's the same structure right so i'm thinking for anyone who's new to streaming unfortunately your chats come to us about seven to eight seconds after you send them because you what you're seeing our video about seven sec eight seconds later so still give us helpful um input but if we ever like it looks like we're ignoring you we're not ignoring you it's just that it didn't come through in time and in the stream you should be able to see your chats when they actually come through in the upper left-hand corner right above marcel's head um okay so we were on site we wanted to give a site a name and now it's got a name um so in our driver we now can just say this name and then uri is gonna be url so it's gonna be this name is gonna be okay so the name shoots so they don't always have the same url right i wonder if we can just pass a single url in from any of them and hope that the driver handles it correctly i think so because if it if it's linked i would i actually wonder why the driver needs the name and the url me too i thought it would just need the path yeah let's go look i was i was very surprised by that same thing all right so find a drive that can serve the incoming requests so site path looks for custom drivers and then it takes all of your custom drivers and then all of the drivers in the driver's path and then it also adds all of i don't know if the difference between this and this is static custom site driver i don't know anyway and then you add in all the drivers that we actually have built in and then for each of them it just asks do you serve it and it's there yeah so we passed the path the name and this mutate uri of the uri but the mutate uri is being called on the driver itself so i don't know why that even matters um so let's go find a driver and serves site path site name uri yeah so it doesn't care about site name and ui it might be just because it's like a just in case a driver cares but most of them won't you know yeah so um if sites are parked you have multiple possible drivers in each one right uh each each site whether it's parked or linked could be served by multiple possible drivers which is why we have to do this um this assign thing so in theory we should be able to get back um so let's i don't know if i think we can just add that file to the auto load um wait is valet driver okay hold on let's figure out cli drivers require dot php okay so this is how it's autoloading all of those so i feel like we have to auto load i might have to either add these to our config or better composer if we pick just this one fire file to composer will it get him correctly will it get these pads right okay you never know until you try right all right um oops files is going to be this and so this is going to be oh but that's that's a vendor file you can't put a vendor file on there okay so let's just put it in an um let's put an app service provider and see if that works um and if not we'll have to put it somewhere more like raw so require once um good lord this is nasty vendor oops there's got to be a better way to do this vendor laravel valet and then what is that uh cli drivers require yeah i thought that would happen did i type it wrong did you provide a path yeah you didn't provide a path so it's now trying to upload it from the provider's folder is it root path or base path base path face paste yeah what is going on with that lag so oh it's already in use because we're being served by valet so it's included right here yeah so we already have it great [Laughter] geez yeah so this whole app will break the moment you run it outside of valet so which is fine which is fine because it's only for valet people great so let's for right now not even memoize it let's just try this yeah okay and then um use valet driver okay so now we need to actually try it so have we have not mapped these all into sites yet so let's map into as we learn from somebody in here who's wonderful thank you whoever that was site class which i think we need to import and then map into site class and then let's say dian or dump and die linked first and then what is that driver okay driver let's see what we get i got double site import uh i do i think it's only once all right um argument passed a site construct must be an instance oh it's the wrong site yeah it's the ballet yeah so it's passing it we need the key for the first one um line eight isn't that the map into now so the map into is passing the array and now this each yes but also they're either sites here so we also need use um app site thank you y'all i didn't realize it first yep got it now yeah um okay okay you were so when when they map it in yeah you're right it's the map in so we need to not map into but we instead need to map with keys oh not no just each no we do need map with keys so i'm trying to remember the syntax for map with keys but i don't remember why the keys though what's that the keys are the um the path which is what we need but the path is also uh yeah because of the but you're right yeah but if the path is available not in the key then we can just do a normal map right yeah um so this would be a site and then return new site with site all right so site uh woof hold on a site is going to be a collection of links links so this is going to be links and then yeah it's going to be links first path no half whited and self-shaved yeah that happens from time to time i kind of think this is what we want but i'm not actually 100 sure let's just see if it works syntax error unexpected parts yeah semicolons missing yep yeah yep um must be a type array object given is links supposed to be in the right wait hold on i guess it's a collection now which should be fine that's why adam weather hates type hinting hey we got a driver look at that hey okay cool all right so each of them now has their driver available um yeah and i don't think there's any nice way of displaying this driver is for laravel so we just have the class names yeah but i think that's fine for now i'm not going to make these tests but i want to stub them out while i'm thinking about them um site test yes um okay so what we want to do for this let's see what are the things we have just manually tested we want to say it gets the right driver [Music] um okay so what other things do we want to test on the site object um yeah we can get make sure it gets the name and the um name off the link yeah name driver and minimum php version as soon as we have that [Music] okay and then we can also look at the link um oops all right it gets so let's see what we have a link i guess just those four name and really these are less about making sure those accessors work and really just making sure that it's parsing everything correctly mark test incomplete and then we'll just do that four times oops that's not what i expected that's what i expected all right so name url path and secured and we will do that another day because i don't want to waste our last 10 minutes on that okay what's next marcel what does your brain want us to do next should we finish up the minimum php version yeah let's do that i think that'll be fun all right so that's on a site um so we need to basically given a path which we have look up composer.json so let's say if to do see if composer.json exists uh if so parse out php version and return if possible um if not or if php not parsable return maybe null because i don't think it's necessarily an exception um yeah there could be like wordpress sites that don't have a json file okay do you think we need to can handle anything other than composer.json in the root i feel like we don't right i don't think so yeah okay so um path does not have a um slash at the end right i don't think i don't think so no um okay and then the simplest way to do it i think would probably be if file um exists composer path return null otherwise let's load it in composer contents just out of curiosity why are you using the file facade in here instead of just doing file exists oh you mean the the level or the because it's test makes the test easier right yeah okay yeah good point yeah uh great question though okay so we actually need to call this one of them so let's call minimum php version on their first site oops so dd linked first minimum php version oops a seam yeah streaming again is a wonderful thing oh like so it loaded so now we just got to jason parsett um or jason decode jason decode i never remember which does true give us a eraser objects okay um i like objects hey do we need what's the default is the default false yeah by default it's an object all right so we need to find require php um so we want to data get so php equals data get target composer contents key is going to be required.php and then if php return null 7.4 great vince says any reason to not just go ahead yes the whole composer data could be nice to see at times yeah i think it's a great idea yeah where are you gonna say marcel sorry yeah we might come up with a feature where we could use the data so if we don't have it how do how should we return it um don't forget sites could have pipes for php versions yeah or right or any kind of semantic check yeah right now i think we literally just return the string and that's it and then later yeah if we want to do anything interesting with it um i wonder if there's version compare in php there is maybe i don't know if if version compare handles pipes i think it might but hansel's a lot more than you'd think and so we could definitely compare it against a couple like what you're running or something oh that's a great idea we could say does this run on your current version of php right yeah i love that good thinking all right so composer contents equals this composer file and then php equals data get that and then if it doesn't yep okay cool so that one's done um so this is going to be returning a string or null i think is how we would do that is am i doing this wrong or is that whole thing only available um in php eight maybe that's why oh you know what return type hints aren't even available in older versions of php okay um data get it's uh felix says how does data get respond to null it just returns a null um i want so you know what we could say um return php oh nope that's also a new php thing never mind i wonder if you can access classes from composer itself what do you mean by classes um okay so composer file unfortunately can this could potentially return a null though right should we instead return an empty array or no i feel like let's return null for now um so if composer contents return null unfortunately which makes this kind of gross but um if php is null in your return why do we have to make this check which data gets no the yeah right wouldn't data get handled you know what you're probably right actually let's just try it real quick i'm gonna open up this really great app that i love a lot called tinkerwell it's made by a friend of mine i know the author okay uh dana get null uh something dot something yep you're right yep awesome so we can just get null uh should spell composer correctly um all right if php is known you're returning null oh right good call if p if if ph pill is null return null good call yeah so we just returned the date again oh look at that so clean hey i love it i heard the guy that made tinkerwell's pretty good php he really is all right so i've got maybe five minutes marcel what else is on your brain anything or do you feel like we've got a good handle on this we should just write it up yeah i think we should just finish here now okay before i get excited about something and then yeah yeah yeah all right so we don't have a view here but we can at least leave it with a dd linked parked i think we made really good progress on this okay so let's real quick go to notion like we always do and say what did we do built a laravel app required valet tweaked valet a bit to work in a laravel app got a list of all linked and parked sites mapped linked and our sites into site class links to a site into link class built out accessors for all basic info in those classes stubbed tests and then we also built out um more complex accessors for composer.json contents php constraints is there anything else we built oh um driver that matches the site cool that's a lot of work in one basically hour-long session all right so let's um oh i don't know why it's oh version compared does seem to handle pipes just fine beautiful i thought it might because i know we used it in um level versions all right so this is basically um acquire our get sites list from valet and build intro hold on can't do it there because i need to add you as a co-author so real quick i'm hiding in everybody so you don't see all the sites in my um my github desktop so this is we need to add a new one add existing repository sorry everybody i know you can't see this choose local path and the local path will be fall back and then we open it add the repository and now we can uncensor all right so the cool thing about github desktop everybody first of all you can review all the work that you've done and you can turn individual things you're doing on and off either at this level or even at the individual line level but also you can very easily add a co-author although it's not letting me do a co-author which is one of the main reasons i use it why is it maybe it only lets you do a co-author if you've already pushed it up to a github yeah maybe let me um do that real quick because i want everybody to see it so i'm going to go on github i know you all can't see it again i'm going to create a new repo under the titan organization and i'm going to name it um valet fallback i guess um and then if we actually launch this we'll put it under the layer of organization but i gotta you know have it working and run it by taylor first um fallback website for valet and then i'll create a repository and then i can unsensor and then i can push it up and i'll push up not this version that we've done here but i'm trying to push up the early version so i can make sure this commit allows me to add marcel as a co-author and let's see if github desktop gets that now okay i'm going to do this and see if github desktop gets it [Music] now there we go so it turns out github desktop only gives you this if it knows it's connected to github oh yeah so it's not co-authors and git it's co-authors in github there is a way to add it yourself there's a specific syntax that it adds at the bottom of it um and jose who works with me uh doesn't use github desktop so he just copied that as a snippet but i find this is much easier to do so i just go in here and then i just add marcel porcio which i assume yeah on github it's just emportioned okay i'm putting out search for user all right there we go um and so then we do that same summary that i was writing out here which is get citelets from valley and build into objects and then we can say get linked sites from valet get parked sites from valet um build site and park classes stub tests and build accessors for a composer should just copy this from notion php constraints and um what was the third thing we did oh uh driver great we commit to maine and now he's going to show up as co-author in that which i freaking love um all right so last couple seconds marcel next time do you want to or we could put it up for a vote do you want to finish this or do you want to work on the other thing we had planned on which is extensions and if we if you want to finish this i can just do this on my own free time um and then we can work on extensions two weeks from now or we can keep working this two weeks from now what's your gut tell you i love working on this some more i think there's a lot of cool stuff that we can add so i agree cool yeah i was hoping you're gonna say that so all right so two weeks from now exact same time nine o'clock eastern same stream same bat channel um we knew the commit message would've been whipped uh we will um we will do this exact same thing and we'll keep working on the same thing so i won't touch it between now and then um uh so that you won't miss out on anything so thank you all so much marcel thank you so much for hanging out man yeah thanks for having me yes so much fun yeah you're looking forward to continue working on this in two weeks yeah me too thank you all for hanging out so much you're all great we'll see you all soon see you
Info
Channel: Matt Stauffer
Views: 1,201
Rating: undefined out of 5
Keywords: laravel, valet, laravel valet, Marcel Pociot, php, web development, web framework, matt stauffer livestream, matt stauffer live stream, laravel valet mac
Id: uTb-xCrvcDg
Channel Id: undefined
Length: 85min 9sec (5109 seconds)
Published: Wed Mar 31 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.