Structuring Laravel Projects: 2024 Edition

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello guys today I want to present to you our new updated course on Lal daily this one how to structure Lal projects with the idea that we will update a lot of courses majority of the courses in 2024 for now for larl 10 and then for upcoming LL 11 in text format so that's the idea we're updating older popular courses first to text format from video so actually this how to structure larel projects was a video course back in 2022 now it is in text form updated for newest trends and newest ideas and examples and this is the second course in 2024 that we updated first was built laral apis my idea my personal goal is for laral daily to be updated as much as possible including version numbers in the titles of the course so how to structure laral 10 projects then we will rename it to how to structure larel 11 projects and so on because it's frustrating you Google something you land on a course or tutorial and it doesn't say which version of the framework or language is it for when it was created and basically can you still trust that code my latest personal example I landed on this data Camp website to learn natural language processing in Python and nowhere it is said when that course was created updated or which version of pyth or libraries it uses although the site seems credible with a lot of professional logos course description and stuff like that even if you scroll down there's no date there's no version so yeah I want to avoid that on laravel daily with updating the coures in the first place and also specifying the version in a really clear way now let's get to the topics inside of the course so the goal and the problem actually for structuring the project is list of these so for example if you don't want to overload your controller methods probably you should offload that logic somewhere else so where is that somewhere so many options in larl but the main thing the main idea of LL is flexibility and it's your personal preference how to structure the project it's your project so whatever fits your team your vision and your project go with that so that's why throughout all this course I repeat that you may move some code to somewhere but it's not must it's May you may you can you can choose but there's no obligation for example validation the first lesson so we're working with this controller method with quite a lot of code it may be more it's kind of almost a fake example but with pretty real structure so for example this you can you may upload that to form request class so you can do make request you can provide the rules here and then the controller is shorter because you use form request class here and then request validated is the result of that class that's one of the option to shorten the controller and then in each lesson by the way I will provide two examples from open-source project for example here in the project of accounting there's a form request class which shows a few extra things first that form request class doesn't necessarily have to be named with form request as a prefix that's your personal preference again and then it's a bit more complicated structure for rules so for example picture sale price and purchase price are variables which are then part of the validation rules so it's an example of a bit more complicated structure which would totally overload the controller if it was in the controller the second lesson of the course is about mutators or observers and they seem to be different topics but if you want to modify the data before saving it for example in the controller store method like this you can Al flow that logic to mutator or Observer so earlier in larl I saw a lot of people doing something like that static creating in the booted method of the model but later mutators came into the scene and people started using this syntax this is a newer syntax of mutators you can do sets start at attribute instead older version of the syntax or in observer you can create creating method with the same logic again these are just the options it's your choice which to use if any because maybe you're a big fan of visibility of the code in the controller so you may totally leave those two lines in the controller and that's fine then the developer would be reading the code AS it is actionable in the controller itself without looking for that logic somewhere else but these are the options another option is to upload the data to services or actions for example to create a user you could create a class called user service and this is just a PHP class this is not a laral class so that's why there's no make service command artison command so you create a method and you just call that method from the controller for example like this or you can type hinted with class name in the method parameter or you can use actions which is almost the same thing so separate class with the method which you then call from the controller the difference is in structure of that class services are more like a structure for specific entity like user service with many methods and action is a class with usually one method like handle execute or something like that which may have private methods inside but usually it's just one action of for example create user update user and stuff like that and again it's your personal preference whether to use service or action or none of them so yeah Lesson by lesson I discuss various options where to upload the logic from the controller with open source examples at the end and with extra resources to read after to that course so this course is kind of an overview I realize that people don't need longer courses they need the answer to the specific question so this course will answer the question what are the options to upload the logic to and then depending on which options you prefer and the projects that you work with you may dive deeper into separate patterns or separate tools or separate options for example in this course I don't talk about DDD because it's a separate very deep dive I don't talk about solid patterns because I have a separate course toour course just on that it's a very deep dive and it's more architectural topic outside of LEL it's more about PHP and objectoriented programming as architecture and it's more theoretical actually than practical so in this course a lot of practical examples on the main core things and most mostly common use cases but with extra resources then you may want to dive deeper into API structure full stack structure with either live wire or view or react and then you may dive deeper into multi-tenancy solid code package creation and other topics from the community like DDD like modular laral pretty recent course on L casts so each of those are like easily 2hour videos that's why I didn't pack them into the same course so the current laral structure course it's mostly about app folder and controllers and structure of those Lal classes in 10,000 Words which you may go through in an hour or so if you have any ideas how to improve it or questions shoot them in the comments below and I may shoot separate videos on this channel discussing specific topics on specific structure places of laral projects and I will keep up dating older courses to LEL 10 and LEL 11 when it comes out in 2024 that's it for this time and see you guys in another video
Info
Channel: Laravel Daily
Views: 10,870
Rating: undefined out of 5
Keywords:
Id: JGYn-qth-VQ
Channel Id: undefined
Length: 8min 37sec (517 seconds)
Published: Thu Feb 22 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.