DEV Community

Discussion on: Node vs PHP

Collapse
addvilz profile image
Matīss

Either, depending entirely on the requirements. PHP full-stack web frameworks are lightyears ahead of Node frameworks in terms of feature completeness and stability (Symfony mostly, Laravel in some parts). So it really depends on what kind of backend you are building. Heavily database-backed REST? You'd probably choose Symfony or API Platform. Have async io and/or WebSockets? Go for Node. Or better yet, Vert.X on JVM.

Collapse
razbakov profile image
Aleksey Razbakov Author

The best answer so far! What do you think of Prisma or some Headless CMS, would you consider it as an alternative to API Platform?

Collapse
addvilz profile image
Matīss

API Platform is usually fine if you are looking to build something serious or potentially / eventually serious. It's based on Symfony so you won't go wrong there, and you get batteries included to work with your data models and build APIs - the drawback is you have to learn how to do it first - headless CMS's are usually much simpler.

That being said, you might as well choose vanilla Symfony with Webpack Encore if you want a somewhat simple API driven backend with the attached Web frontend. For bootstrapping and prototyping medium complexity projects this is also fine.

If, however, the only thing you need is plain CRUD and you do not foresee a serious need for future customization, headless CMS is the way to go from a productivity standpoint. From those, Strapi (Node) and Directus (PHP) are my favorites. Feel free to demo both and see which one could be best for you.

As far as Prisma - interesting project, haven't used it. From the birdseye view looks like it's a database mapping library and it generates a static client to the database from a database schema - and if it works as advertised and without the cloud component, it could be very useful in some use cases. There are some drawbacks and gotchas to schema-driven code generation though - conceptually, your database abstraction is "database-first" and your codebase is no longer your single source of truth. Then comes ensuring everyone has the same generated code version, how do you share the generated code, etc. This is by no means a new concept - such tools have existed for quite some time now in platforms where code generation is more common, ex. see JOOQ.

Thread Thread
razbakov profile image
Aleksey Razbakov Author

I am doing my project with Node already more than a year now. Cloud functions in Firebase and REST with Express. It got wild and chaotic. I can't get it organized. I can't even test it properly. While at work I am getting deeper with Symfony, which got all those Bundles, Interfaces, DI.

So I am hesitating now on how to proceed. I want to get most of logic out of cloud functions and do them as microservices. What I want to achieve is a good logging and some admin panel to be able to navigate quickly and flexible through the data. So far I understand that the best way to connect microservices is through some kind of queue and state machine. Firebase has a big limitation on filtering (which I need most for admin) and I am afraid I can't control the costs (it can get wild with more data), so I want to move all logic on own server and be able limit what and when to process. So far all triggers are on onWrite functions of Firestore documents. So it can get out of control real quick. I haven't found yet any alternative to Symfony in Node yet, that can allow me to do all the things. Neither I can migrate 100% to PHP, because there are some packages that only available in Node.

After a while working with Firebase it gets annoying, because you have to find workarounds to build your data model. Normalized thinking from MySQL you can forget right away. Neither NoSQL thinking works, because Firebase is not flexible enough with queries.

It's very painful and annoying. I already have an idea how to build it with API Platform in a way, but I want to give it a chance everything based on Node. Unfortunately I can't find good examples of something complex built on Node and it's like walking around and trying to find all the small pieces first and build a new thing. That always felt wrong in PHP world. There is always something working out there, some framework, some concept, some structure. In Node it feels like lots of small libraries which do the same thing and have releases faster than I deploy a new version of the app. And sometimes projects just get archived without any explanation of what happened.

I still have hopes that I have wrong perception and it's just takes time to learn and find a right thing.