DEV Community

Sudheer Tripathi
Sudheer Tripathi

Posted on

Nodejs developer gets blown away by Laravel

"They've got docker setup upfront, that's awesome !!" - on the first day of learning laravel

I don't know what you think about PHP, but the developer experience with Laravel has been really good, and it motivates me to write this blog.

Laravel deveolper

My background with other Frameworks / Libs

Most of my projects have been around FullStack Javascript / Typescript, which makes me look at Laravel from a different eye.

Here are the top 5 things I liked about Laravel.

Automated dockerizing with Laravel Sail

  • Managing different database types/versions and switching between them for different projects gets messy.
  • With Laravel Sail, you can get your laravel application and the database of your choice within a docker container in no time.
  • The Best part, sail cli connects you with your dockerized laravel application from outside docker.

Server Side Rendering with Blade

  • If your frontend is complex, separating it out would be better and ideally NextJs / NuxtJs / etc would be the way to go.
  • But, when it comes to writing SSR code within your backend application, this framework really shines here. Writing SSR code with Laravel Blade is way cleaner than the Express + EJS duo.
  • You get more powerful directives, multiple ways to nest components, custom directives, etc. If your component involves heavy logic, you can create class-based components too.

Consider an example where you have to show some posts to a logged in user, skipping the first post.

With EJS

With Blade

Laravel Blade creates an "aha" moment.


Application bootstrapping and Dependency Injection

  • The Laravel application instance is called a service container. You can bind a class instance to a service container as a singleton and reuse it wherever you want.
  • Laravel automatically resolves constructor injection and method injection (kinda like NestJs).
  • With AppServiceProvider you can easily swap out what dependency gets injected by default.

Bind to app

Auto Inject


Migrations, Factories and Query Builder

  • Writing migrations and seeding the database is easy.
  • Personally, I have used Sequelize heavily and working with migrations in Sequelize has some initial learning curve.
  • I found laravel migrations cleaner. Also, laravel has out of the box developer-friendly query builder, like TypeORM but more flexible.

Consider the example below where we want to include relations Author, Category, Comments with a Post table and filter the results by Post body and Category name.

Laravel Query Builder Example


Top-notch support for miscellaneous requirements.

  • With NodeJs frameworks, adding(and updating) npm packages is more frequent, you usually install an npm package for any miscellaneous requirement.
  • Laravel has inbuilt/supplemented support for authentication, request validation, cron jobs, mailing, event handling, http requests, notifications, caching, file storage, OAuth etc.

The above reviews were solely based on developer experience. Laravel is relatively slower than other backend frameworks, but it does fine for most of your requirements.

There's something unique to learn from every framework (I learned some new design patterns in Laravel) and it's important to not get attached to the one you are using.


Hiring Alert

I work as a Software Engineer Intern at ClearGlass, we are a Cost Transparency company based out of London, UK.

ClearGlass is looking for Senior Software Engineers for the Engineering team. Most of our tech stack is in NodeJS / PHP. Know more about us and apply here. Learn about our tech stack here
See you there šŸ‘‹.

Top comments (2)

Collapse
 
offfffz profile image
offz

If you like a fullstack framework like Laravel, Iā€™d like to introduce Ruby on Rails to you šŸ˜‰

Collapse
 
vladi160 profile image
vladi160

If u want such a framework Rails is the standard. There is a sentence "Rails like framework " and Laravel is that.