I've worked with Laravel for 10 years.
I've come up with 5 pretty random lessons from those 10 years.
- - - - - -
1. Laravel became a full-stack framework. So should we.
I'm a core PHP back-end dev, and that's what I enjoyed with Laravel. But then we had Vue, Inertia, TALL-stack, and now it's a mix. That shift to full-stack happened gradually, and then suddenly.
But it reflects the market: everyone these days needs to be a full-stack, at least on some level.
- - - - - -
2. You can structure your projects however YOU want.
Laravel allows you a lot of freedom. Services, Actions, Repositories, Jobs, custom PHP classes, more strict design patterns - whatever you want.
It's a blessing and a curse: newcomers are often lost what is the RIGHT WAY. And there isn't one right way.
This comes with a caveat: the right way depends on the context of your project and the guidelines of the company you're working with.
So whichever structure you choose, the goal is for others to understand it and maintain the project.
- - - - - -
3. Most performance problems will be with DB.
Whenever I see some page/API loading slowly, I check the Debugbar/Telescope first for the amount of queries.
Then I check for individual slow queries.
Then for the amount of RAM that the queries take: maybe they return too much data?
So yeah, all of that Eloquent before any fancy restructuring, Octane or other optimization.
- - - - - -
4. Rely on framework. Packages come and go.
After 10 years with Laravel, I see so many packages abandoned or just not keeping up with the framework changes.
So, I advice to trust only the packages that are:
1. Either from trusted creators who have reputation of maintaining things
2. Or, small enough so you would easily replace them in the future
And quite often, framework itself has a very similar functionality as the package offers.
Of course, packages are often a way to deliver project v1.0 faster. But, with every package, know the consequences for your v2.0 of your project.
- - - - - -
5. Writing tests is NOT hard.
Laravel team and especially Nuno Maduro went above and beyond so any developer would be able to start writing tests QUICKLY.
So, if you are in a camp of "I don't have time to write tests", it's a lame excuse now. Heck, you can even generate tests with AI.
- - - - - -
Any other "global" lessons/advice from working with Laravel you would add?