2021-03-19
1468
#js libraries#php
Kenneth Ekandem
37731
Mar 19, 2021 ⋅ 5 min read

Getting started with JavaScript for PHP developers

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

Recent posts:

Understanding and supporting zoom behaviors on the web

Understanding and supporting zoom behaviors on the web

Understanding and supporting pinch, text, and browser zoom significantly enhances the user experience. Let’s explore a few ways to do so.

Fimber Elemuwa
Oct 9, 2024 ⋅ 7 min read
Comedy and tragedy masks symbolizing Playwright Extra's ability to extend Playwright with customizable plugins for both stealth and interactive browser automation tasks.

Playwright Extra: extending Playwright with plugins

Playwright is a popular framework for automating and testing web applications across multiple browsers in JavaScript, Python, Java, and C#. […]

Antonello Zanini
Oct 8, 2024 ⋅ 9 min read
CSS logo in front of pile of green matcha tea, which represents the matcha.css library discussed in this article.

How to style HTML with matcha.css

Matcha, a famous green tea, is known for its stress-reducing benefits. I wouldn’t claim that this tea necessarily inspired the […]

Emmanuel Odioko
Oct 7, 2024 ⋅ 10 min read
CSS typography in white on a vibrant red geometric background. Article will focus on the CSS backdrop-filter property and its various functions, including blur, grayscale, brightness, and drop-shadow.

How to use the CSS backdrop-filter property

Backdrop and background have similar meanings, as they both refer to the area behind something. The main difference is that […]

Oscar Jite-Orimiono
Oct 4, 2024 ⋅ 10 min read
View all posts

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