Kenneth Ekandem Software engineer with four years' experience in PHP and JavaScript. Currently working as a backend developer for Codekago Interactive.

Getting started with JavaScript for PHP developers

5 min read 1468

Javascript php Developers

After reading the title, you must be wondering, “Why are you migrating to from PHP to JavaScript in the first place? And why is it important to write an article about it?” Well, as a PHP developer, switching from PHP to JavaScript was a big move for me — and a difficult one, too.

I had to find a JavaScript framework I could relate with — one example being AdonisJs because it had the same MVC (model, view, controller) architecture as Laravel. From there, I gradually moved on to other frameworks, studying the syntax and adapting to the enormous differences between PHP and JavaScript.

One of the big reasons I started using JavaScript was because I wanted to improve my frontend skills. The language also supports client-side programming, and the JavaScript ecosystem is by far one of the largest — you can literally find any solution to anything if you use the right keywords. (Stack Overflow is still my main source for solving problems, though 😂.)

So why JavaScript? Why not any other language?

So at first, I had many other options, ranging from Ruby and Python to Swift and so many others. But the big reasons I settled on JavaScript are its flexibility, its easy interactions with JSON formats, and, of course, its DOM manipulation capabilities. Its wide range of use cases was also attractive — things like building web, mobile, and desktop applications, creating 3D games, and others too numerous to mention.

Unlike PHP, JavaScript supports building for mobile, web, and desktop applications alike, and it does this effectively thanks to the fact that it allows developers to plug in so many external files that work asynchronously to give you the best results.

The JavaScript community is another big reason. It is broad and active, and you can choose basically any programming pattern and get the support you need. For example, are you a strict programmer? Well, you can work with TypeScript. I can keep going with the reasons, but let’s keep it short.

Advantages of using JavaScript

JavaScript was built as a client-side programming language that conforms to the ECMAScript specification. It follows the same fundamentals as every high-level programming language, which include arrays, loops, statements, functions, and other building blocks that make up a language. With JavaScript, you can build both frontend and backend applications thanks to Node.js and Deno.

Using JavaScript as a backend developer comes with tons of advantages, including flexibility, usability, and lots of frameworks to choose from. But arguably the most spectacular advantage is its community — not to mention the job opportunities.


JavaScript supports multiple application architectures depending on the type of application you want to build. The JavaScript application architecture ranges from MVC to isomorphic, SPA, multi-page application, and others. PHP revolves around MVC architecture and really can’t break out of it.


JavaScript has an event-driven, single-threaded, non-blocking I/O execution model. Such a model is ensured by the event loop and Node clustering. The asynchronous nature of Node.js enables it to run through the entire codebase simultaneously without waiting for some functions to be executed.

PHP is characterized by a multi-threaded, blocking I/O execution model. Unlike JavaScript, PHP is synchronous; this simply means that the next line of code cannot be executed without the first being completed.


When you’re just starting out with JavaScript, one the first things you notice is its usability. The simplicity of the JavaScript syntax makes it easy to adopt any JavaScript framework as long as you know the basics of the language. JavaScript is also highly maintainable and supports tons of packages, which allows it to be more effective in delivering world-class applications.


JavaScript is a full-stack application language that allows developers to build web, mobile, and desktop applications without relying on external APIs or another language to render the frontend. PHP, on the other hand, is strictly a backend language that simply doesn’t match the flexibility that JavaScript offers.

Application compatibility

JavaScript supports dedicated server hosting, which allows it to run large-scale software applications, 3D games, and other awesome stuff.

PHP is a general-purpose programming language and is primarily used for building dynamic web applications. PHP favors more of content management applications.


To start, JavaScript is the most popular language on GitHub. It has one of the most robust and active communities of developers and is being used on a global scale by every major companies around the world with an active web presence.

PHP also has a very large community, but over the years, new developers have leaned more towards frameworks running on JavaScript than PHP.

Language cross-compilation

Many languages can be cross-compiled and translated in JavaScript — languages like Java, C#, Lisp, and even BASIC. To top it off, JavaScript has supersets like TypeScript and CoffeeScript for developers who love strict programming.

The best JavaScript backend frameworks for PHP devs

As a PHP dev trying out JavaScript for the first time, it is important to know which frameworks will feel familiar as you ease into using JavaScript. To make a decision, you have to consider:

  • Which frameworks support the architecture(s) you are used to?
  • Which have database connection and configuration?
  • Does the framework support frontend rendering in-app or use APIs to communicate with the frontend?
  • How easy is it to maintain and scale the application you are building with this framework?

To make the decision a bit easier, here are a few JavaScript frameworks I’d recommend. These frameworks use different approaches to programming, and their architectures differ. But based on your application type, they are the choices I would recommend.



I am starting with AdonisJs because it supports the MVC architecture Laravel is popular for. AdonisJs is a JavaScript framework used to write microservices and build boilerplate applications.

It takes inspiration from Laravel and follows the same programming pattern, which encompasses using providers and dependency injection for code organization. Even the file directory of Adonis.js is similar to Laravel, and it’s the best framework to start with if you are a Laravel developer.

AdonisJs is very effective in building APIs and it’s a lightweight application so it does not demand a lot of storage space or configuration to kickstart it. It also supports a bunch of databases like MySQL (which PHP is famous for using), SQLite, Redis, and others.


Express.js Logo

Express.js is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications. It was also designed for building single-page, multi-page, and hybrid web applications. Over time, it has become the standard server framework for Node.

Express fully embodies server-side programming and is highly compatible with MongoDB, but it can be used with other databases like MySQL if you are not really familiar with Mongo. While Express supports building frontend applications, it’s highly recommended for use when building APIs.

Like AdonisJs, Express supports the MVC architecture but is also open to other patterns — the choice is yours.


Nodejs Logo

Yes, Node.js can also be considered a backend framework even though it is a full-stack application framework.

Node.js is a JavaScript runtime built on Chrome’s V8 JavaScript engine. Node uses an event-driven, non-blocking I/O model that makes it lightweight and efficient. As an asynchronous event-driven JavaScript runtime, Node.js is designed to build scalable network applications.

Another beauty of Node.js is that other frameworks like Adonis.js, Express.js and numerous others are built on Node.js. So yes, you can use Node.js to build a fresh new framework configured to your taste and with your own architecture in mind.


Next.js Logo

Next.js is a full-stack web application framework that really blurs the line between backend and frontend. Next.js is a pre-rendered React app in the client-side that users can view and interact with, which can be considered the frontend.

At the same time, it also handles server-side rendering and API routes, which can execute server-side code and access data in the database — thus, it can be considered the backend.

Next.js also supports TypeScript, and it uses the monorepo architecture, which stores all config and test files in one place, allows atomic commits, and in general keeps all your isolated code parts inside one repository.


As a developer, it is difficult deciding which framework or language to use to build an application. It will always depend on the use case, and I’m not here to make the decision for you. I am simply sharing my opinions and the reasons why I started using JavaScript for building my applications. Don’t get me wrong — I like PHP, but I prefer JavaScript. I hope this article gives you some perspective as you decide what to use and when.

Are you adding new JS libraries to improve performance or build new features? What if they’re doing the opposite?

There’s no doubt that frontends are getting more complex. As you add new JavaScript libraries and other dependencies to your app, you’ll need more visibility to ensure your users don’t run into unknown issues.

LogRocket is a frontend application monitoring solution that lets you replay JavaScript errors as if they happened in your own browser so you can react to bugs more effectively.

LogRocket works perfectly with any app, regardless of framework, and has plugins to log additional context from Redux, Vuex, and @ngrx/store. Instead of guessing why problems happen, you can aggregate and report on what state your application was in when an issue occurred. LogRocket also monitors your app’s performance, reporting metrics like client CPU load, client memory usage, and more.

Build confidently — .

Kenneth Ekandem Software engineer with four years' experience in PHP and JavaScript. Currently working as a backend developer for Codekago Interactive.

6 Replies to “Getting started with JavaScript for PHP developers”

  1. Migrating from php to JavaScript. One of the best frameworks to go for is Expresswebjs which enables you to build structured, secured and scalable application.

  2. Laravel livewire or Laravel+inertia.js is the way to go for me, but 9/10 times Livewire wins. Most of the points you pointed out can easily be challenged when you need third party functionality such as import/export csv,authentication, charting, oauth, pdf generation. All of this is easily done with Laravel, but not so easily with a JS backend solution, i’ve done projects in both sides, im glad i found Livewire, i drastically reduced js code in my aplications and whenever i need it, alpine.js does the rest of the job. If i work with inertia.js, Laravel still helps tremendously because i dont have to write any api like in a classical api project, Laravel is the workhorse providing the data, handling authentication… etc, then vue.js is for the front end receiving data from Laravel as props. But still working with Livewire handles all of this with less code and dont have to go through some annoying stuff that vue.js has. The only time where i would only use a pure JS solution will be if the app is a chat app, a prodict builder with a rich UI which changes on every click and event or a social media app like facebook, which is the reason why they created React, because that solves their problem.

  3. You highlight all the benefits, but none of the downsides of JavaScript. Types is going to be the big pain point, as you will likely learn the hard way.

    Typescript doesn’t solve this except at the static level. When your application exchanges data with the external world, by which I mean anything external to the code you wrote, you’re at risk, as there is zero type-checking in function calls, in data exchanges via web requests, or anywhere else.

    The results range from, best case, your script crashes, which is often hard to debug, because the wrong type can travel through many function calls and Promises etc. before causing an error – to, worst case, your program executes, but does something entirely else than intended, making the problem not only difficult to debug, but difficult to detect in the first place.

    And maybe you think you’ll get around all that with tests, but reality is, nobody manually tests every internal function in a codebase. Are you going to cover every function with unit tests to see how it responds when you pass it every conceivable wrong type? Of course not, your test suite would end up being 90% noise. Are you going to add type-assertions to every argument in every function? Even if you do, authors of third party code you depend on did not.

    Even if you test everything like crazy, and fight like hell to keep unsafe code out of your dependencies (completely unrealistic), at some point, you would most likely have to concede why some of us insist either on static guarantees, which Typescript does not provide, or run-time guarantees, which JavaScript does not provide.

    PHP’s type system isn’t great, but at least it has type-checking in function calls. It now has type-checked properties as well.

    This simple fact keeps me firmly on the side of PHP, if the choice is between the two.

    For all the fun and cool stuff that JavaScript does, and for all the ugly in PHP, I’m not even tempted.

    But good luck with that. I hope you find what you’re looking for. But I’m pretty sure you’ll find something else as well.

  4. Thank you for your feedback, I just discovered Livewire. The thing about Laravel applications that are built for large-scale use is that you find out there still in one way or the other rely on JavaScript. My point is, why not just build an application with one language handling both the client and server-side?

  5. java script is not secure. Any one can see de code with little or no difficult. Use resources of the computer which PHP does not. 45% of web servers use php.

Leave a Reply