Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

coder's avatar

Started with node js but missing laravel too much

I started my current project in Node js with Express. Though i watched some tutorial for this and learn quite a bit of node . but honestly i'm missing laravel very much .

Specially Eloquent ORM, coding style, readable syntax , code beauty and lots more.

HATS OFF TO YOU @JeffreyWay

Since i'm digging into nodejs and found very cumbersome. I mean WHAT THE HECK IS THAT. There is so much code for a tiny task.

Wouldn't it be cool if i could code in node that doesn't hurt and in a readable manner like Laravel??

Can you guys suggest me kinda all in one package or couple of package for node js to get the same feeling like laravel( packages for database handling , caching, Error handling, acl, ORM like Eloquent, MVC ).

0 likes
12 replies
topvillas's avatar

You could try out http://knexjs.org/ and http://bookshelfjs.org/ if you're missing a query builder and ORM.

There's an excellent course about knex on pluralsight.

If you want a framework then please have a look at Express, Hapi or even Koa (if you want your head turned inside out).

topvillas's avatar

Heh! I just updated my reply. There's a whole shed load of npm packages that'll make your life easier. Unfortunately, it's not a one stop shop, like Laravel but it's all there if you spend a bit of time looking.

1 like
coder's avatar

thanks @topvillas . i'm using express . Since i didn't worked on node , express that's why i'm not able to select which package should i use .

martinbean's avatar

@coder I imagine most people have the same feeling moving from one language to another. However, you’re comparing a framework to a specific language implementation. Of course you’re going to miss things like ORMs in Node.js. The idea is, you install a package that fits your needs.

I’ve not really done any in-depth programming with Node.js, but npm (the module repository for Node.js) is pretty mature these days and I’m sure you’ll find packages to give you things like an ORM, connecting to a database, caching objects etc.

I also think it’s unfair to compare any two technologies in this style, as the second is always going to come out unfavourable to one you’re most comfortable with if you’re criteria is: “I don’t like X because it’s not Y.”

2 likes
coder's avatar

@martinbean i agree with you . Btw can you suggest me some useful packages in node which can fulfill my requirement. I found many packages but not able to figure out which will be ideal for me.

martinbean's avatar

@coder As I say:

I’ve not really done any in-depth programming with Node.js, but npm (the module repository for Node.js) is pretty mature these days and I’m sure you’ll find packages to give you things like an ORM, connecting to a database, caching objects etc.

Unfortunately I can’t really suggest any specific packages as I’m not familiar with your project’s needs. But if you want something like Laravel, why not just use Laravel?

kocoten1992's avatar

I'm digging in, have run into similar problem, it seem all these node lib lack of the god feature Eloquent provide, whereHas (putting constrain on relationship)

willvincent's avatar

express absolutely can be used along with other packages.

I have a project that uses mongoose, an ODM for Mongo. Interestingly I started the project initially with mysql as the DB, using Sequelize, an ORM for MySQL, PostGres, et al.. Changing from one to the other was very basic.

Here's what one of my mongoose models looks like:

module.exports = function(mongoose) {
  var Schema = mongoose.Schema
   ,  findOrCreate = require('mongoose-findorcreate');

  var ResourceCostSchema = new Schema({
    name: String,
    cost: Number
  });

  ResourceCostSchema.plugin(findOrCreate);

  console.log('Resource Costs');
  mongoose.model('ResourceCost', ResourceCostSchema);

};

I have an autoloader of sorts so that to load all of my models I simply have to require the directory.. the index.js in that dir takes care of the rest... The most relevant portion:

var fs = require('fs');

module.exports = function (app) {
  var mongoose = require('mongoose')
   ,  config    = app.get('config');

  // Prepare mongodb connect string
  var connectString = 'mongodb://';
  if ((typeof config.db.user !== 'undefined' && config.db.user != null) && (typeof config.db.pass !== 'undefined' && config.db.pass != null)) {
    connectString += config.db.user + ':' + config.db.pass + '@';
  }
  connectString += config.db.host;
  if (typeof config.db.port !== 'undefined') {
    connectString += ':' + config.db.port;
  }
  connectString += '/' + config.db.name;

  // Support defining mongodb connection string via MONGOLAB_URI environment variable (e.h. on Heroku)
  if (typeof process.env.MONGOLAB_URI !== 'undefined') {
    connectString = process.env.MONGOLAB_URI;
  }

  // Set up DB connection
  var db = mongoose.connection;

  // -- SNIP --

  // Add Email and Url field types:
  var mongooseTypes = require('mongoose-types');
  mongooseTypes.loadTypes(mongoose);

  console.log('Preparing database...');

  // Process all .js files in the directory except the index.js file
  fs.readdirSync(__dirname).forEach(function(file) {
    if (file === 'index.js' || file.substr(file.lastIndexOf('.') + 1) !== 'js') {
      return;
    }
    var name = file.substr(0, file.indexOf('.'));
    require('./' + name)(mongoose);
  });

  app.set('db', mongoose);

};

I have a similar "autoloader" for my routes, which are broken into a few different files, etc.

Express definitely is a framework. However, it's a much less robust framework, and a rather different paradigm than laravel. The asynchronous nature of JS can be considerably more challenging to work with, and since more often than not you're actually building the entire server, not just the app that runs atop apache or something, there is more effort involved. Thinking about it that way you should realize that you're actually not doing much work to build a completely custom web/chat/etc server with node.

1 like
willvincent's avatar

Frankly, I think the biggest problem with node is that there's so many packages available, knowing which to use is challenging, and getting them to play nicely together can be a huge pain!

1 like
pato's avatar

Hey check out this site http://adonisjs.com/ I have not checked it out yet. I give my review when I do, but the documentation feel like laravel.

1 like

Please or to participate in this conversation.