hajimasan's avatar

Laravel and design patterns

This post is about laravel because is what i use but i guess it can be any framework or without framework.. but anyways.

So when i started coding everyone told me to not worry about design patterns because i would not understand them untill later on my career .. well it's been a couple years and i still don't get it https://kodi.bio/ .

At work everytime i just write the code on controllers/models and if it gets messy i can fix it by extracting the code to a service class, it feels like everything i need laravel can do it out of the box and i don't have to overcomplicate anything.

I've been reading lately about how to structure my code and design patterns, and yea i understand the code but i just can't get the concept or why would i need them, maybe i'm using them without knowing it? I found myself trying to force my code into a design pattern, when the whole point of a design pattern is to use it BECAUSE you need it, well i never found any reason to use them..

I keep reading about facade, singleton, etc, and im just like .. what? why would i need that?

i would love the help from any one that went through the same thing or just any tip would be fine.

Thanks!!

0 likes
1 reply
jlrdw's avatar

Facade is a static looking call using __callStatic().

Laravel uses some singletons for dependency injection. Just read about the service container.

As far as "design patterns" there are some in the framework, but for laravel I stick with MVC.

I would say if you are writing a framework then be more concerned about some of the patterns.

Edit:

Have you viewed the lessons here on design patterns?

Please or to participate in this conversation.