Mastering Long-Term Laravel with Benaja Hunzinger

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
yes thank you very much for the introduction get stuff done I develop like this I like to ship features and I don't like to get lost in those nitty-gritty details and you will also see that in my application not everything is perfect and that's just the way I develop I often prefer speed over Perfection and I had to realize but the hard way that in a long project like this sometimes it's useful to do or to aim for Perfection to also gain more speed in the end or in the long run and with that I want to welcome you to my talk about mastering long-term laravel projects and to share my experience what I have learned about as russan said about the last six to seven years but who even is this guy that is standing here in front of you I am benaya I am a software developer currently working as a solo developer for a very very large farmer that farmer he has many employees that he rents out to other Farmers so he needs a software uh for for that to manage everything I live here in a beautiful little village called epsa but without further Ado let's get started one day six or seven years ago that that man it's a friend of me of mine came to me and said I need a software I need a way to manage my customers and also I need a way that I can document how many hours my employee worked at which customer so then I can make the billing for those customers and currently he used like Excel or something like that it was not very great so I said I was in my second year of apprenticeship and I said yeah sure I can do that I had no idea how to build that applications but I wanted to learn it so I looked in on internet and found laravel and that it would be a awesome framework and also View and I decided I will go with it and so here you just see one of the first versions you have your customer overview you can edit your customers and that was the main page you can add employees and say how many hours they work at which day uh for that specific customer and you can create PDF and he could then send those PDFs to his customers for the billing now the application looks a little bit different many many new features uh were added in that time it was for me always great because um my friend like from from this company he he always said I have an idea let's build this one and I was like yes sure and currently I always have to slow him down but um you see it it looks little bit different and also here we have the scheduler he can schedule all his over 100 employees um where they work um at what um what customer so how did I start I started with V2 and larel 5.6 today I migrated or sever year ago so I migrated to V3 and also continuously migrated laravel now I'm on larel 10 I will migrate it probably this summer to 11 and you cannot see anything probably on that image that's just the database it it's grew and there are many tables it's um yeah it's awesome to develop uh especially when you find try to search something the first paint point or the first really really big paint paino was when I started to migrate from view2 to view3 view3 has many Breaking changes and so it was it took me a long time to update all my components and everything to V3 but almost even harder was to change like the VY version VY is just a component library but they rewrote everything for view3 and also changed their API it was now like a completely new framework and there were also some stuff some components missing that I used and I was so Ang angry on them I just ditched them and said I will build it on my own and now or not not exactly on my own um I used headless UI it's uh from Tailwind they have nice component and component library that has no styling in it and you can do everything uh The Styling everything on your own it looks very beautiful afterwards uh if you also invest the time here uh an a good other solution would be Shian UI uh shsi for view it's actually for react but that's the view version and I haven't used it but it looks also very promising and I can really recommend it to for for larger projects to use component libraries like this one because I have now my eight um or so seven or eight form components that I use all over the place and it's me who's defining the apis of those components that are in my project and underneath I just use headless UI so when never headless UI I I just saw now recently they released version two if they have breaking changes I need to change it in like my eight files or so and in all over the project I can leave my code untouched if I if I use a a compounded Library like beautify I have to change it on 1,000 places in my whole code base so here I can definitely say it is worth to invest or to aim for perfection in your components that they are really um they're really made in a good way that you can use them all over the place and what I also would recommend what I don't have currently is to test them like separately just the components because currently when I make a change to a component that is like rather big or add new functionality I'm not quite sure if all the other um if it works um everywhere in my project still so I would highly recommend if you do it like this is awesome but test your UI components but on the other hand larel from larell 5.6 to 10 the migration was very easy thanks to laravel shift if you don't know laravel shift I highly recommend you to check it out you can it's a website you can log in with your GitHub account select your repo and then select your version you want to migrate on and it does everything for you it creates a pull request and it also warns you if it cannot migrate stuff by its own and then you can do it by your own so that is very awesome and I'm very happy that I chose larell because I can still use my app even though it's six or seven years old when I've started developing that application also the file structure it grew always bigger and bigger over 200 controllers and 71 models so at one point I decided I have to switch from the default LEL um fold structure to a domain driven development uh fold structure and I will show you that in my code um I can collapse everything here on the left you see it's a very basic larel project I hope yeah it should be big enough but and you have the the app folder with all your basic stuff if I go to http controllers here I still have left over some controllers that I did not know where to put them so they stayed here but the main thing I want to show you is located in Source domain and here we have separated all those different domains for example everything that has to do with off everything that has to with forms or for example order management and then if we go into here we basically Al see a regular larel app and for example HTTP controllers here I have my controllers or the requests the jobs and somewhere that should be the models here and like this everything is structured nicely and I can find my controllers so one great resource is laracast they have a course modular larell it's almost the same like domain driven larell just that they call it modular but if you if you have a a larger application or you want to you know that you start one I recommend you that you watch that course before and it's really good so translations one thing I'm very proud of is that he can manage his translations by his own so I can just translate it once by De so he has like some stuff and for that here I'm now logged in as a customer and if you give it the right rule you can I'm choose currently we have uh do German and French but you can also CH choose translations and now you see the keys and that's very useful for for my customer he has an admin he can then just copy that key because sometimes you have the same words at multiple places and he does not know which key he has to change now so he can just copy that key go into the admin panel into the settings translations search for the key click on it and edit the translations that's very useful uh especially especially for him then next thing was validation and probably you all know the struggle that you want to validate some form input and you want to validate it in real time so the user gets feedback while he's typing but you also do not really want to do it twice and I started with doing everything twice so I I validated in the input in view but also on my API but then larel published a package it's called Uh larel precognition and with that we can do something like that when I'm here we can manage our company cell phones here if I want to add now a company cell phone it's I will try to demonstrate that in in uh code if we say we want to add a new U field over here the only thing that I have to do is company phone form go all the way to the bottom add a text uh text field give it a name price and label usually I would also obviously translate that one but or let's do the translations then you can also see that one validation at tributes company phone price and now I can just with an extension for vs code enter the German one and also translate English French oh I don't have Network okay let's do that later so uh no it should work maybe okay um so let's cancel cancel that one now I need to go to the create company phone and here I use that's the use form Hook from precognition I just have to add the price it's null just for the reactivity to work and now I can go to my company re company phone request and that's a regular lar Val request as you all know I go to my rules uh the price should be re required and uh numeric like this and now if everything works I can can go back here something is not working oh my death server stopped [Music] working reload the page we see we have the price here I can enter a model name and if I add a price but it's not I yes there we see uh the price field must be a number we we get the the response immediately immediately I can enter it save it and it's saved so and that's just so awesome to have as a developer only do your validation rule once and not have to do uh do it twice for testing I started my project without any tests and in in the beginning it was okay I actually think it's still the right decision to start without tests I was just beginning to learn and it was okay but after two three years I noticed that with with new features I cannot sleep anymore so when I have to release them so I noticed yeah I need tests and for that I decided to go with larel dusk especially for the end to- end tests and I don't know who of you have already done endtoend tests they are a pain or at least to me I really don't like them because it is so a pain to set up and they fail often they're slow but I have to say I was quite surprised by larel dusk because it makes it so easy to set up your database and I will also show that to you when we now go to the comp company phone tests then we can see it's also like a pest test you can Define it just like this and we can arrange our test very simple and use our factories we create an employee we make it searchable that we can find it in the front end we make a company phone and then we have and now that's the pest part here we BR say we want to browse we want to browse this very page and you have to for each page you have to create a class where you can Define custom functions so then your tests stay very clean and now the only thing I need to do is go into the company phone uh company phone uh Factory add a price here we say it should be a random float between zero and 1,000 and we have to go into that great company phone page that and then on the base company page and here that's also something I can really recommend I that's custom logic from me I created like those text fields and with that I can Define the form what input field should there be and what is very awesome for example combo box Fields when we go back into to the website and create a new company phone we see here I can search for employees and with that logic I can just say I I search for an employee class and now if I provide it I only have to provide it for the test the ID of the employee and it does everything for me and so also here for the test sometimes it's I I had to invest like a day or so to to just Define all my forms like this but now I can test it very easily and if I need to add a new field for example now I just make this one I have to Define now it's very easy a text field is named price and if I rerun those tests um it should still pass actually I forgot to run it before before it would have failed and probably now it should pass yes we see everything passes that's the test here so test is awesome and now the last thing I want to show you is post talk post talk with post talk you can do some amazing and um yeah monitoring of your app for example the the best feature of post talk is um or for me one of the most mind-blowing features were now I closed it by accident to go here we go here onto session replay and [Music] find yeah it does not really matter this one here I want to show to you you can see what your users are actually doing so when it's finished with buffering you will see a video from a user um like navigating the page and this is so awesome to see how your users um act react or no yeah act with your with your application and then you see I I started to notice oh here with this button they they always they don't know where to click or they don't find it or or they click somewhere where they should not click and I had like multiple entries yes here you see it I had like multiple entries that are always had always the same name and I asked why do they create twice the same entry and then I noticed oh yes there is not showing a success message so they don't know if it's created or not and for that it's just very awesome to debug and to see what your customers are doing how they behave and the best thing is is it's for free so you only have to pay when you have like many I don't know over 1 million or even more like entries or so so for me it's more than enough and even if you exceed like a certain um user limit you can just say it should only log like every 10th user or so so then you're good to go until very high amount of traffic yes then one last thing I want to share is the deployment first I only did it with flal Forge it's great and it worked great till now but uh one thing I added is GitHub actions I build my front end with GitHub actions and then just fetch or trigger the forge deployment to then further like just get the uh build output get it with Forge so I can reduce the down time then it's only like 20 or 30 seconds where it builds the composer packages and everything like that has to do with building the front end is done by GitHub actions so very nice hack to just have almost zero downtime with larel Forge and if you also have to build some JavaScript and with that I want to close and thank you for your attention
Info
Channel: Laravel Switzerland Meetup
Views: 321
Rating: undefined out of 5
Keywords: Laravel, Switzerland, Meetup, Long-Term, VueJs, HeadlessUi, PostHog
Id: e8_raKZKmKY
Channel Id: undefined
Length: 21min 11sec (1271 seconds)
Published: Sat Jun 22 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.