Why it’s bad to code PHP on Windows environment

I see quite a lot of PHP developers using Windows operating system. And there’s nothing wrong with that. But if you look closer…

Ok, I’ll be honest – I’ve been there myself and I know the difference. Before buying my first Macbook and switching to Mac OS, I was a Windows user, using XAMPP to run local web-server. And it was OK, but…

One of the main goal for testing the software is that you should be testing in an environment as close to a live environment. And this is where it goes wrong.

What is XAMPP, or other alternatives, basically? They install all the software you need to code PHP and make it work on your machine. It’s Apache, MySQL and PHP itself. And it’s run on Windows environment, of course.

But if we want to move to live server, especially with projects on Laravel, it’s usually a dedicated server with SSH access and Linux operating system. Which raises possibility of “It works on my computer but doesn’t work on the server, OMG why” to a whole new level.

Oh, and did I mention that live server will likely have Nginx instead of Apache? And another argument – have you tried to play with subdomains instead of localhost/project folder-like URLs in your XAMPP? Good luck with that!

Not only that. The problem with Windows that it’s all based on, well, windows. I mean, graphical interface, drag’n’drop and mouse. Which is fine and awesome for a home user, but in development world you can do so much more faster with command line. And if you are not used to it, you will have problems deploying projects.

It was actually OK earlier with frameworks like CodeIgniter which didn’t need any kind of command line interface to make it work. Current framework leaders Laravel and Symfony heavily rely on thing like Composer, Artisan etc. So you won’t even be able to move on with just drag’n’dropping or copy-pasting files manually.

To be honest, you can actually use Windows command line (I prefer Git Bash then, actually), but again – it’s different from Linux environment and some things might work unexpectedly or even not work at all.

So, your options are to work locally on Linux, or buy a Mac which at least has a Terminal really close to Linux one. And yes, learn those commands, it’s not that difficult.

Ok, I hear you scream:

“But I don’t want to use Linux and don’t have money for Mac!”

I know, I know. Linux is not that friendly for home users or gamers, and Mac hardware is quite expensive (though if you compare to similar specifications Windows laptops, actually really close). But there is a way.

I present to you… Virtual Machines!

virtual-machines

Now, whatever operating system you’re using, you can install Linux OS within your OS. And I will tell you more – it’s absolutely easy. With Laravel Homestead.

Actually, there are several things to be installed, but as a result – you will have not only Linux environment, but also all server software to run your web-projects there.

As I switched quite recently myself, I agree that there is some learning curve here, and some stuff to configure here and there, and something might not work out of the box, but hey – as a result, you will be one of the cool guys! I’m joking, of course, it’s not about being cool, it’s about being a professional developer – and Linux is a part of LAMP stack, whether you want it or not.

Final argument from Laravel world – have you ever watched Laracasts videos? Jeffrey Way uses Terminal for all of his lessons and it makes the result so simple that it’s hard to find an argument not to use it. Same for any video by Taylor Otwell, creator of Laravel himself. Have you ever seen them using Windows?

Like our articles?
Check out our Laravel online courses!

29 COMMENTS

  1. I would put another item to the list: every tool used to develop are made for linux and then ported to Windows, and all of then are command line based. So knowing how to use the command line is a must for any developer.

    I’m stuck in a Windows laptop, tried to develop in this environment couple of times, but it just doesn’t work well. In Linux, things works way better. Thanks to Vagrant e Laravel Homestead, getting a Linux environment up and running is a piece of cake.

  2. If I may spent my two cents in regard. I think that if someone is not willing (aka refusing blindly) to learn the tools that will make their life easier and most of all richier they should change job.

    I know, those are hard words.

  3. I’m not using Windows myself but Microsoft recently announced they will have Unix shells support on next versions with an embedded Ubuntu distribution so there’s that. 🙂

  4. Not to mention the font rendering on Windows. Or the overlay of windows and panels, the amount of space they take, the overload of stupid buttons, and the amount of distracting system notifications. Those are not details when you’re looking to code 8 hours a day.

  5. Claims in the article that are not true:

    – It’s hard to use to subdomains with Windows.

    If you really just worked on localhost/project, that surely means you did not understand much of your environment. There’s no problem at all using http://whatever.you.want.to.use.and.a.fancy.tld if you know how to configure Apache or nginx.

    – You can’t just copy and paste because of composer and artisan.

    Both composer and artisan work perfectly on Windows. They might be ugly because of ANSI codes (as they are used in artisan), but except for that both tools are not a problem – like many others. But yes, you definetly should use Git Bash. It makes working so much easier.

    And honestly, macOS stops being userfriendly the moment you open the terminal. Before this, it’s just as copy and paste and drag and drop as Windows is. On the terminal you really must know what you are doing.

    Okay, let’s face it: Web development on Windows really is not good. It’s harder to get things to work, eg. you need to check your capitalization in filenames (but as far as I remember, that’s a problem on macOS too). Or you´re stuck with 32bit versions of PHP in XAMPP, which becomes a problem, if developers don’t know the proper use of int. Or our favorite WAMP environment is configured wrongly. Eg. that gave me quite a few headaches with older versions of EasyPHP, because it had a /home alias configured in its Apache conf.

    But the reason for this is not Windows, it’s developers, who are way too centered on their machine. And this is not just a problem on Windows. There are quite a few packages for NodeJS or gems for Rails, that do not work on Linux, because someone thought he must fix a problem which only happens on macOS and others make it a dependency. Yes, I’m aware, that there might exist similar packages for Windows or Linux. 😉

    It’s not Windows web development that’s broken. It’s web development in general. We are working on projects, that should be usable on any device possible, but make working on it intentionally harder by creating tools that only work on our “favorite operating system”.

    • Oliver, thanks a lot for your reply. Valid points on most of the things – you CAN make Windows work for web-development. But it’s still kind of a “fake”, don’t you think? If PRODUCTION environment is usually Linux (I have tried to make PHP + Windows IIS work, painful), why do we have to make our lives harder to learn both Windows tools and Linux tools? Isn’t it more convenient to just learn one set of environment things?

      And yes, I agree it’s not Windows fault, it’s web-development ecosystem. But it’s more like “if it can work like this, doesn’t mean it should”.

      • I’m sorry you have trouble with getting windows to work the way you want, but that’s not a problem of the operating system, it’s a user error. I have no issues with windows/laravel/xampp.

    • Hey,

      of couse you shouldn’t use IIS with PHP – although I did for a while, but that’s long gone. 😉

      I mainly use tools that exist both for Linux and Windows. git, composer, npm, gulp, etc. As long as the tools are written correctly, there shouldn’t be problem. Also PHPStorm works great.

      I don’t use fixed paths or stuff like this in my projects and try to stay completely independent of the OS.

      I’m pretty sure, if it works on my Windows environment it will work on a Linux server. Of course there is sometimes a short hassle on the first deployment, but that are mainly capitalization errors in filenames.

      • Totally with you Oliver. If you are working on Windows you should be using a business version of Windows, Professional or Enterprise, which include HyperV virtualisation. Out of all the VM’s its by far the simplest and works the best with Linux.

        Then there is the new Bash on Ubuntu on Windows or WSL, still a work in progress but I am playing with it, not bad.

        I like Windows because I like to build PC’s, and my machine would set me back about $7000 if it were a Mac. I love Mac and plan on getting another Macbook very soon, but I don’t think it’s far to say it’s bad to code on windows. I follow everything Jeffery does on Laracasts with no problems at all.

        Each to there own I say, do what makes you feel good. I have been a PHP developer for 10+ years and find the Mac Vs Pc war a waste of energy.

  6. I installed homestead on my PC at home, it’s awesome. But at work, I don’t have administrative rights. So, what to do? I ended up using XAMPP (a portable version), Sublime Text, and Dropbox to host my project’s files and keep everything in sync. Both at home and work. It has a lot of flaws, but I couldn’t come up with a better idea.

    • In my opinion, the main flaw is that you don’t have administrative rights at work. So the company doesn’t trust you to do your work? (or you mean your work is not for development and you use that computer for your needs)

      • Yeah it sucks. The computer isn’t for development at all, it’s just to do administrative works. But as a computer maniac myself, I develop a bunch of macros and excel sheets to do my work faster and end up with some free time, also I can use it in my lunch hour. I can dream of a portable version homestead, right?

    • You don’t need admin rights to run Apache, PHP, MySQL (unless blocked by the Windows firewall and the firewall is administered via GPO — but port 80 is probably already open)… They can be installed anywhere. PHP is portable without having to get a “portable” edition. Same for MySQL; just use the “no installer” zip.

  7. Yes, your title seems right until someone finds the right tools for the answer.
    For Windows, I encourage developers to use Laragon. If Laragon is your right tool, you’ll be happy and have more time to concentrate on making great apps for your users.
    Remember, your test environment is the same as your production environment is great but your development environment don’t have to be.

    • Are you kidding ?
      laragon is really just another xampp port thats gone way wrong.
      Do yourself the favor of using vagrant instead you dont need to use the homestead box you can make your own if there is something you dont like in the homestead box.
      You always want your dev environment to be the same as production, why? You know it will work out of the box and you don’t need to run around and patch your code.

      • I’m not kidding. Laragon is rolling on the right way and the truth is that it’s useful for many developers.
        It is different from XAMMP/WAMP from design so:
        – It’s fast: Fast setup (less than a minute), fast startup (less than a sec), fast services bootstrap (with its own service manager instead of Windows Service)
        – Quick Development: with 1-click sharing your projects to the world, auto create virtual hosts, 1-click create web projects (WordPress, Laravel, Drupal, …)
        – Easy Operation: install other versions of Apache, PHP, MySQL 5.7 or MariaDB is simply download and extract, auto self-certificated generator, portable so that the environment can be moved easily around (USB, another folder, another laptops)

        It’s not a replacement for Homestead/Vagrant but if your projects work well on Laragon, it is not bad to code PHP on Windows. It’s a pleasure 🙂

        Again, for dev environment, you don’t need to have Linux if your production is Linux. Also, you don’t have to use Docker if your production is Docker containers based.

        PS: I’m using Vagrant for only testing purposes. I’m not against Vagrant but life is short and Vagrant issues are still many (329 Open/5377 Closed).

  8. or you could just code in sane environment like Windows but test on ubuntu vagrant box, you know?
    it’s much easier to run VM with test env than to restart your PC to boot linux or to struggle with everyday tasks if you switch completely
    “but in development world you can do so much more faster with command line”
    and here steps in cmder, good luck with finding something as great on your mac, hint: you won’t find it, sorry

  9. I like how this article gives exactly zero actual examples where code that works in one environment will fail in another environment. “On Windows you use a mouse! On *NIX you type commands! It’s COMPLETELY DIFFERENT! BOO HOO!”

  10. It feels like a windows bashing article. I work on both and both offer the same stuff if you dont use Valet. PHPStorm and Chrome looks the same. Who cares about the other stuff of the OS. They both have terminals.

    I think you missed out a real problem of working on Windows: using caps in files. If you proper cased a class name and lowercase the filename it still works. Until you push it live and linux says the class doenst exists.

  11. “you should be testing in an environment as close to a live environment”

    Then you go buy a Mac instead of using Linux lol, what a contradiction. I’ve been using Linux for my development for about 7 years and there is absolutely no excuse to develop PHP applications on Windows, absolutely zero. Nothing in PHP development is done better on Windows as it is on Linux

  12. I agree that Homestead makes it easy to create a great dev environment for laravel on a Windows machine. That is NOT to say that it is easy for someone who is not well versed in linux commands to make this work. That is the biggest issue with the way Homestead is advertised. It sounds like “Hey Windows users, just install this and get to work on your code” . That is not the case, unless you are lucky enough for your machine to not have any hiccups with the rote “copy this into your command line and hit enter” instructions. For most primarily windows users like me, you will be googling for help for a while before you get Homestead working correctly and predictably. The good news is that you will get better at understanding bash commands.

  13. I am a web developer and can say window is not a problem if yo use it correctly. I installed thousands of php applications frameworks on windows using xampp and cmd and deployed them on live servers, not a single time I got any thing wrong so how can it be windows. So stop changing others mind if you don’t know about it.

  14. Without getting into a “battle of the OSes” discussion (and for the record, I despise Windows 10 with a passion — especially when it reboots in the middle of a build even though I supposedly hacked it to NOT reboot), the spirit of the article is well taken.

    The way the article is written misses the mark.

    It’s NOT “why it’s bad to code PHP on Windows environment”

    Rather it’s “why it’s bad to use something like XAMPP to code in a Windows environment”

    XAMPP has created a generation of developers who call themselves “full stack engineers” without having a clue.

    It literally takes 30 seconds to install MySQL on Windows. Simply unpack the zip file, the NO INSTALLER version, and place in the Windows folder of your choice.

    Then spend another 5 minutes to setup my.ini — and — gasp, possibly actually having to learn something about the database while editing a configuration file.

    Same goes for setting up PHP and the webserver!

    When someone doesn’t know how to type httpd or mysqld from the Windows command prompt, that’s NOT an OS issue in the least. Windows is a target rich environment for blame but not in this case.

    That’s a lazy developer depending upon tools which abstract things which should be FUNDAMENTAL knowledge to them.

    Tools should not be an excuse to not fundamentally understand what is going on under the hood/bonnet. The tool is there to automate, make efficient, support. When people use a tool without understanding how it operates and the product goes to production and it’s crap and/or the product is rubbish to begin with, well, nobody should be the least bit shocked.

LEAVE A REPLY

Please enter your comment!
Please enter your name here