Answer the question
In order to leave comments, you need to log in
What is the place of OOP in Laravel?
Recently, I have noticed the popularity of the Laravel framework. Since web development is in my business interests, I decided to see how it works. And, reading the documentation, in all the examples I see the use of static methods. Controllers, forms, models - static everywhere, that is, to put it mildly, this has nothing to do with OOP. Maybe I'm just looking in the wrong place, please correct me, experts in this framework.
Answer the question
In order to leave comments, you need to log in
Laravel provides the ability to use dependency injection, not facades. And this is the recommended approach. So it is not necessary to use static methods. In the documentation, all this is described so that developers can quickly start riveting sites, etc. without bothering with things like dependency inversion. Well, maybe it happened so historically, I didn’t write anything on Laravel, Silex / Symfony is enough for me. But writing in Laravel is normally possible.
This is the first time I've heard about this framework, but still, what confuses you with static? Now almost all modern frameworks use statics, and all in order to be able to access any necessary methods or properties from anywhere.
Statics are used as facades. It is very easy and convenient to use it. But I agree that if the hands are crooked, then you can do this ... although this is possible in any framework ...
About IoC
More information
Here's a good talk about patterns in php, including the hackneyed façade that people don't want to understand www.slideshare.net/sparksphill/software-design-pat...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question