Should You Switch from Laravel-only to Vue+SPA?

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello guys in this video I want to share my opinion on being a full-stack developer and should you switch from being laravel developer back ender with only some JavaScript to be in a totally full stack start from UJS and leave laravel s api with totally different architecture an inspiration for this video I have published a video last week which became really popular practical an example of switching from laravel to vgs with api and there was one comment which became pretty typical in my videos or in my articles from people who don't like the idea of switching to the front end first like david in this case and he listed the reasons why here but let's talk in general about full staff development and should you switch and disclaimer this video is an opinion based on my own experience and I haven't practically experienced everything that will dimension on this video but I will give an opinion based on my experience and what I've read online first the definition full stack developer who is full stack developer if a company publishes the job advertisement for a full stack developer what do they actually need and there are two actual cases which are totally opposite for some cases full stack developer is a back-end or who can tweak the JavaScript and apply the framework like jQuery or some minimal UJS so they know enough front-end to be a full stack and list of UJS on their CV and that is a majority of developers these days so back Enders who used to code only PHP then laravel and then adopted some of the JavaScript and I suspect that majority of you are in that group in that category myself included actually I know enough JavaScript to be dangerous so to speak so technically I can't call myself a full stack developer but the other side of the spectrum our front-end first type of developers who start the project from huge areas or react or angular or some kind of JavaScript framework and then leave laravel only for the API layer and I see a lot of developers trying to switch from the back-end mentality to the front-end mentality because it's sexy these days because it seems that everyone is building s.p.a is now UJS and all of that sexy stuff but let's think about it what projects are good for that switch and one good it depends on the context it depends on a lot of things so if someone tells you use of UJS do single page applications learn the AP is just because you need to do that that's wrong thinking because it depends on the team you have on the project you work with on the budget on the risks if you don't deliver on your infrastructure on your previous experience with front-end and back-end on the project future so will you need a mobile application or not so the decision for the architecture should be based on the project and only situation not on someone's opinion that bougie-ass is sexy and also the problem is that the switch seems quite easy to learn some view Jas and then you already know how API works and laravel and this video that I'm showing on the screen 22 minutes of demo of simple view Jas page it's kind of a misleading message that it is easy it may be easy on the first step so to create a page but then if you get deeper you go into authorization and authentication and even that topic in itself has so much confusion about that how to check the roles and permissions both on the front end and the back end what driver to use larvell passport or new sanctum and by the way do you know the story of the sanctum back in December 2019 tailor art well creator of flare ago posted a few tweets asking the audience how do they do authentication with you and API and laravel after a few tweets it became clear that people were all over the place with that there was no clear information from laravel documentation or from rubber how to do that as a best practice so everyone was winging it somehow and doing it their own way or the where few articles written and then everyone was following those so people were using laravel passport just because it is released so tailor was kind of forced to create a tool for more simplified authentication at first it was called air lock mode was renamed to sanctum and even after that laravel team member mohamed has to explain stuff to people releasing the video like this one on what is better to use for tokens for sessions for authentication so if you get deeper into view j s with s pa and API world it becomes quite complex and then in the end you have to support two applications laravel and UGS and both of them quite complex but it's not that bad I'm not trying to scare you here there's totally a good case for those single page applications and that raises the fundamental question when should you switch and when should you use that UJS and API logic for the project and the question is are you working on a website or a web application think about it even the word SBA short for single page applications it contains the word application so if you are working on a public facing page like a blog like an eShop like Yellow Pages directory of companies or something like that it's okay to have public website without that reactivity of UJS front end first and also it may actually even hurt public pages to have application logic because for SEO you have to have clear URL structure rendering of HTML so Google would index it in a well structured manner and stuff like that so for a lot of things single page application logic would be actually harmful and more complex to them maintained but I'm not saying you shouldn't use view j/s at all there is a perfect scenario for that so you could think of UJS as a replacement to jQuery and vanilla JavaScript with just more structure more object-oriented thinking so for that case it's totally fine so you have the public page of each shop and then some element is dynamically rendered after some click and for that you can use view GS totally but to switch to front end first that requires totally different effort so I will give you three reasons when it is worth to switch your application to be single page application first reason is user experience if your back-end rendering is slow enough so people need to wait for a few seconds for anything to appear on the screen that's pretty bad then it's better to load HTML and CSS and JavaScript much quicker in a fraction of a second and then render each element with time imagine - like Google Analytics or any reporting tool or dashboard or something like that or you can imagine any Windows or Mac application like even a browser imagine you click any link on the browser and then the whole browser is refreshed relaunch like a new application that would be pretty terrible user experience right another reason to switch second reason to switch if your platform will be multi-platform so it won't be only on the web but also you need mobile application maybe something on a SmartWatch on Tesla or whatever then you have to have a bi first and third reason kind of similar to the second one if you have a separate team for the front-end who wanted to care out the front-end only so you have people who would work only on vgs and would only consume the api and you yourself on the backend would work only on the api and now i will give you three reasons three bad reasons to switch first reason is that someone says that you need to be proper full stack it maybe CEO of your company it may be some girl on the internet someone outside of your company at all so if someone says you that you need to be a full stack and you need to build single page applications that's wrong way to switch also similar reason if you want to follow the trends so you see the trend of single page application and you want to follow that wrong reason and third wrong reason is if you just want to try it out so again those reasons are pretty similar and interconnected but if you want to try it out as a architecture you may try it out on your side project somewhere after work or in your spare time or ask your manager to have your like 20% time just for experiments but don't do that on real projects until you actually have experience on some planer out things and also there is a great hacker news discussion around an article that none of my projects want to be single page applications the article itself is quite good and real life scenario explaining but also read the comments I totally recommend you that final note I want to mention some new tools to make the mix of both worlds it is also a new trend in last year's so you can have so-called server-side rendering with tools like Knox Jas I haven't tried myself but there's a lot with so you can read around that also guys like spots he received their own package laravel server-side rendering and finally probably the hottest thing on the market is laravel livewire so just this week this article was published that laravel livewire is a game changer and it allows back-end developers laravel developers to basically stick with laravel and not care about view GS or javascript or MDM or anything like that and for back Enders it's totally a game changer but I found another article pretty popular which is making the case against laravel livewire and this is a great article about architecture in general and also practical so a total recommend to read that and at the end of the example here's the result so livewire totally makes the case for not caring of JavaScript and BM do you react or anything on the front end but then architectural II it's a question what then happens with the project how it is maintained how it is supported because it violates quite a lot of principles of separating the concerns because for quite a lot of time people were trying to separate back and from front end with even different people working on those things and this livewire kind of mix it all together with quite a lot of potential questionable impact I would say and here's the list and then in the article every item is explained and probably separation of concerns is my biggest point to make so that is your choice if you want to use something like livewire feel free to do that and it looks cool and it does work it does the job but think about how that project will be maintained a year after that five years after that who would do that and will it be actually easier to maintain so these are my random kind of thoughts I'm jumping here and there but I hope you get the message my message is that don't blindly follow the trends of whatever technology whatever framework put that in context if you need to deliver quickly on low budget with small team go without any of UGS laravel as your friend you don't need any single page applications if you are putting architecture for the future with potential mobile application and you have time and budget for and good understanding how those things work then dive deeper into SBA's so this is my overall message do you agree or disagree let's discuss in the comments final note if you do want to switch to the API way of doing things inside of our quick admin panel laravel generator we have API generator so you just tick the check box and you get the API crud controller with all the methods like stores show update and destroy like a typical Oracle resourceful controller with also API resources and for authentication we use lateral passport by default but you can turn it off so check that out at quick admin panel calm or I will link that article in the description so you can just read around
Info
Channel: Laravel Daily
Views: 31,651
Rating: undefined out of 5
Keywords:
Id: cL_D86o6yRA
Channel Id: undefined
Length: 11min 44sec (704 seconds)
Published: Mon May 25 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.