Week 11: Language Servers

Started the week off and also our first week in Kigali, Rwanda. Mercy and I spent the whole day inside the house. I started trying my hands at improving the Monaco editor on PHPSandbox. Tried a couple of things that didn't work.


I had a coaching session with Denis, a colleague at work, it was quite enlightening to hear his thoughts about writing weekly notes. I'm basically copying this from him. Our private apartment in Kigali offers breakfast for $5, so we decided to try it out. The chefs were quite friendly the meal was nice. All this time we’ve always woke up at a time past the breakfast period, after which the chefs had dismissed.

The majority of my colleagues were attending the IRL meeting, so, there wasn't so much to do at work so I had to use the time to do some personal developments. Using banks in Nigeria does come with a lot of restrictions. I started getting an error in an attempt to transfer some money for exchange into Rwandan Franc. After mailing and contacting bank support, I could get around it. I think the chatting platform for Access Bank should be improved as it keeps disconnecting rapidly and I have to start the conversation all over with another support staff.

We finally tried Nigerian food in Kigali. We found a Nigerian kitchen in Kigali and ordered fora fang. We didn't enjoy it as much as we do back in Uyo.

I learned, while on a call with Denis, that it is possible to control my personal laptop from my work laptop using the built-in Screen Sharing app on Mac. It was nice to finally find a simple way to get into my personal laptop while at work.

One of the specific areas of the PHPSandbox editor that I want to improve is code intelligence. So I started looking into Language Server Protocols and how I can get a basic sample working. I figured Language servers seem to use STDIO (Standard Input and Output), IPCs, and TCPs to communicate with them. I'm still trying to understand why that is the case. Why not WebSockets directly?

I finally got Intelephense and PHP language server working after so many headaches and trials. I encountered a deadlock with the PHP language server which turns out that some errors weren't being handled properly after digging and reading some existing GitHub issues. I finally concluded the project is outdated and might not be a good decision in the long term. I could also see a lot of issues opened on GitHub from different users.

Intelephense on the other hand works fine and supports the latest PHP and framework stuff but it's written in JavaScript and seems to be a closed source. This is both good and bad. Good that it is JS and works in the browser directly, but bad as PHPSandbox will be limited to its features or lack of features.

There also seems to be Phan, a PHP static analysis tool that has a built-in Language server (added with the intent to replace the PHP Language server project). I’m yet to get this to work.


One question that was on top of my mind is if a Language server needs to have access to the folder where the project lives. I think the best answer I have for now is NO. Judging by how LSs (Language Servers) are meant to work - that an LS should be agnostic of the editor.

I was able to confirm this after a few trials that includes having two models (PHP files) sent to the LS. One of the models uses a class from the other model. The LS was able to reference the other model as the source of the definition.

I had gotten an Intelephense Premium license some months back and I finally used it and it worked. I was able to do things like smart refactoring, auto imports for use, etc.

Another question I had was "How will the LS know about the files in the vendor directory?". My quick answer was that we will have to tell it about them somehow. I could realize why my IntelliJ Idea or VSCode editor always says "Indexing...." I guess that's what I'll need to do, but I don't know how yet. At this point, I feel the need to connect my small sample to PHPSandbox where there are more files anyway.

I couldn't go further with this as I figured I need to migrate to Webpack 5 for the sample I worked with to work on PHPSandbox which is on Webpack 4. This broke quite the whole app somehow and had to make all the dependencies (especially Tailwind, which I had to upgrade from v2 to v3) compatible with Webpack 5.


After battling with tailwind styles not applying, I figured it is due to the new content setting. Everything worked fine as soon as I update the content setting. It's annoying how something small can mean a lot of stress. At the end of this, I declared I won the Webpack battle. I read in some places that Migrating from Webpack to Vite (A faster and new bundler) was easy. I quickly get on to see if that's the case. Indeed that was the case but I still need to do some mods as Vite uses import and not require. A major example of this is the SVG icons.


I ran into issues with the Ace editor on the homepage as well and was also fixed along with the icons.


I woke up very late on Saturday and ended up not writing code at all. We went around the city (Kigali) trying to buy food ingredients. We went to the market where we almost got duped 😂. Mercy and I decided to go to a club that is just beside our apartment and we got bounced 😂. The bouncers told us that the club is private for that night. That was the second time we tried going to a club and both times, we got bounced. Maybe it just isn’t meant for us 🤷🏽‍♂️