In the end, Laravel is just PHP

Don’t let the framework make your forget that!

Jean-Philippe Murray
jpmurray.net

--

I’ll always say it to anyone listening to me: I’ve learned basic coding skills in college, but I’ve never been a hardcore coder. The journey to self learning how to code, back in the late 90s, early 2000s, wasn’t filled with actual good websites to learn the cool kids the tools of the trade. There was some, but if you really wanted to learn how to code properly, you’d open a book. A very, heavy, sometime dictionary sized book (maybe I’m exagerating a bit). And I wasn’t even remotely close of doing such a thing. Websites where nice for me, because the tutorials would show me how to do stuff, quickly. They didn’t bothered with heavy concepts (anyway, PHP wasn’t even doing proper OOP back in the days!) and I didn’t want to learn those anyway: I wanted to code stuff and see the result in my browser. At some point, I went away from web development for some years and thing changed. A lot. Frameworks where god sent to me, because I would finally stop repeating myself and worry about the basic stuff. I particularly loved (and still do) Laravel for that: it does the basic stuff for you (and even more), and let you worry about your product, while being easy to learn and work with.

But there is a danger to let the framework do the basic stuff for you: you let the framework think for you. It’s not always a bad thing (this is why it enables you to rapidly build stuff, sicne you trust it’s way!) but if you’re like me, you can sometime get stuck with those easy things and forget the basics.

I got hit with that reality when I was thinking of some way to divide data in models, and I was over complicating things (like one do). Speaking with Michael McMullen about it, he told me that I could have only one relationship by using condition in my model.

It’s crazy because I never, not even once in the time I’ve used Laravel in the past years, thought that I could do conditions in a relationship method. And it’s obvious I can: like Michael said, “in the end it is just a return statement”.

Do you realize how simple this can make things? I would probably have put 3 different relations in there, guessing which one to use on the fly in my controller or something! And it’s not because I didn’t knew I could do conditional, I just never questioned the way of the framework. If a relationship was made with a method that only returned a statement, it never occurred to me to do something else. But I can!

In the end, it’s just a return statement.

When making bread (say, a CMS), I can use a hand mixer (PHP) for my ingredients and knead the dough myself, but I can also use a shiny KitchenAid stand mixer (Laravel) that will do the mixing and kneading for me. It’s less effort so I can concentrate better on making the jam I’ll put on it later on.

Laravel is not a language, it’s the framework for a language and you can still think like the framework is not in your hand. Never get that out of your mind

In a future post, I promise not try not to make shitty analogies.

--

--

Studied religions and its people for some time, now I’m back working with the web. Passionate about technologies, the human being and the human becoming. FR/EN