X ProfileGitHub Profile

PHP Language Server

Repository

One of the first languages I built apps professionally in was PHP. Not because it was a language that I particularly loved, but because it was rather commonly available on shared hosting environments, and so many clients specifically wanted proejcts to be implemented in PHP. Plus, it was one of the first langauges I learned to do web development.

Around that time, Visual Studio Code had just came out, and I fell in love with it as an editor. There was only one problem with it — the development experience for PHP was not great. So, asking myself "How hard can it be?", I embarked on a side-project to make the PHP development experience in Visual Studio Code the way I wanted it to be and had gotten a taste of from its built-in TypeScript support.

One decision I made early on was to write the language server for it in PHP. My thinking behind this was that I could re-use existing parser libraries for it that would stay up-to-date with new language features, and that I would be able to attract more open-source contributions if the project was written in the language of its target audience.

There were some interesting challenges this that came with this — PHP is designed so that each script is ran once for each request to produce the response, but language servers needed to be stateful long-running processes responding to RPC calls over STDIN/STDOUT. On top of that, PHP is single-threaded and most of the standard library is blocking. I took some patterns from NodeJS to solve this, replicating the event loop pattern from JS and using abstractions similar to Promise and async/await using generator functions.

Eventually, I switched jobs and didn't need to use PHP anymore, and I frankly got a bit burned out on the project by the amount of daily issues that were filed (notably issues, not a lot of PRs) that are somewhat inevitable for any project with this many users. Most were polite, but a significant number every week came in an entitled tone or were downright rude. My hope of seeing a lot of open-source contributions didn't really plan out the way I had hoped and I wanted to shift my own attention to other projects. Nevertheless, I look back fondly on this project and it was my first open source project reaching millions of downloads. Plus, it got me connected with Sourcegraph and had me ultimately join their team!