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 Solid Js Props A Complete Guide From Beginner To Advanced

Understanding SolidJS props: A complete guide

Let’s see how SolidJS props work to promote component reusability, exploring basic to advanced concepts for a complete understanding.

Temitope Oyedele
Dec 7, 2023 ⋅ 11 min read
Eleventy Vs. Next.js Static-Site Generation

Eleventy vs. Next.js for static site generation

We evaluate Eleventy and Next.js and compare both static site generators in terms of performance, developer experience, scalability, and ecosystem.

Nelson Michael
Dec 7, 2023 ⋅ 11 min read
Build Full-Stack App React Goxygen

Build a full-stack app with React and Goxygen

We show how to use Goxgen to scaffold a full-stack React app. See how to integrate React with Go and modify Goxygen to suit your project requirements.

Clara Ekekenta
Dec 6, 2023 ⋅ 8 min read
Express Js Adoption Guide Overview Examples Alternatives

Express.js adoption guide: Overview, examples, and alternatives

Express.js is a Node.js framework for creating maintainable and fast backend web applications in JavaScript. In the fast-paced world of […]

Antonello Zanini
Dec 6, 2023 ⋅ 17 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