PHP Through the Eyes of a .NET Engineer


| August 1, 2017 | in

We are a software design and development shop. So when asked which tech stack we prefer we’ll always give some answer around our the preference for the Microsoft stack. We tend to use C# / .NET for most code writing, SQL Server for databases, and Azure for cloud storage.

However, we recently undertook a PHP project and I really enjoyed the opportunity to ship software using another tech stack. Like many developers I have played around with other stacks in the past, but getting a chance to actually ship software from it was a great opportunity. While I have completed Ruby software and applications written in all JavaScript, this was my first PHP project.

We do a lot of web work, which basically means we do a lot of JavaScript. We like to use TypeScript when doing JavaScript, and when using TypeScript we really get a lot of what we like with C#: a statically-typed language where the compiler is the first unit test. But with PHP we don’t get the first unit test, the static build of our code. This was something I felt the project was lacking early on in the project. It was like we lost our security blanket.

Architecting in PHP took a little getting used to. It seemed like we could never get into a rhythm, but eventually we got it looking like the rest of our projects by structuring the code in our standard taxonomy of managers, engines, and accessors. We also got some really good unit testing going.

Early on, I also missed the extremely well-documented .NET framework. PHP / Laravel is documented, but not nearly to the level. In general, I think this is one of the areas a .NET developer will notice some pain when moving to another tech stack. Microsoft set the bar really high in this department.

Another pain we suffered was the lack of Visual Studio (VS) which, in my opinion, is probably Microsoft’s best product. It offers a wide range of functionality and does it extremely well. The best part of VS is you can install it and get running without spending hours setting up a configuration. No playing in an NPM soup just to display some text on a page.

As the project went on I quickly began to love the “no build” work. It had been a while since I had worked with Ruby on Rails, which also doesn’t require builds. Modifying a PHP page then refreshing the browser makes for a quick turnaround. When building UIs bound to data returned from PHP, this is a game changer. In fact, I’d say it spoiled me. After returning to a .NET project, the need to wait for a build was first thing I noticed (“Why do I have to wait?”).

Another area where PHP really shines is mocking. Because C# is a statically-typed language, it is tough to do something like mock out a method. In C#, we end up with a whole lot of ceremony to mock out a method using moq or JustMock. But with PHP we just call a single method and pass it a function.

Lastly was the editor problem. We tried a few PHP editors but in the end we choose PHPStorm, and we loved it! PHPStorm is a first-class editor, with even more features than VS. If you have never used a Jet Brains product, you really should. PHPStorm was so good I’ll give JetBrains’ Rider IDE for .NET a try.

What did I learn from this project? PHP isn’t that bad. While it will never be my favorite language, I have a new-found respect for it. PHP, when paired with Laravel, is a very good tech stack. Now I wouldn’t worry about taking on another PHP project.

Related posts